@@ -3,30 +3,31 @@ export type Point = {
3
3
lat : number ;
4
4
lng : number ;
5
5
} ;
6
- export type MarkerDefinition < MarkerOptions , InfoWindowOptions > = {
7
- '@id' : string ;
6
+ export type Identifier = string ;
7
+ export type WithIdentifier < T extends Record < string , unknown > > = T & {
8
+ '@id' : Identifier ;
9
+ } ;
10
+ export type MarkerDefinition < MarkerOptions , InfoWindowOptions > = WithIdentifier < {
8
11
position : Point ;
9
12
title : string | null ;
10
- infoWindow ?: Omit < InfoWindowDefinition < InfoWindowOptions > , 'position' > ;
13
+ infoWindow ?: InfoWindowWithoutPositionDefinition < InfoWindowOptions > ;
11
14
rawOptions ?: MarkerOptions ;
12
15
extra : Record < string , unknown > ;
13
- } ;
14
- export type PolygonDefinition < PolygonOptions , InfoWindowOptions > = {
15
- '@id' : string ;
16
- infoWindow ?: Omit < InfoWindowDefinition < InfoWindowOptions > , 'position' > ;
16
+ } > ;
17
+ export type PolygonDefinition < PolygonOptions , InfoWindowOptions > = WithIdentifier < {
18
+ infoWindow ?: InfoWindowWithoutPositionDefinition < InfoWindowOptions > ;
17
19
points : Array < Point > ;
18
20
title : string | null ;
19
21
rawOptions ?: PolygonOptions ;
20
22
extra : Record < string , unknown > ;
21
- } ;
22
- export type PolylineDefinition < PolylineOptions , InfoWindowOptions > = {
23
- '@id' : string ;
24
- infoWindow ?: Omit < InfoWindowDefinition < InfoWindowOptions > , 'position' > ;
23
+ } > ;
24
+ export type PolylineDefinition < PolylineOptions , InfoWindowOptions > = WithIdentifier < {
25
+ infoWindow ?: InfoWindowWithoutPositionDefinition < InfoWindowOptions > ;
25
26
points : Array < Point > ;
26
27
title : string | null ;
27
28
rawOptions ?: PolylineOptions ;
28
29
extra : Record < string , unknown > ;
29
- } ;
30
+ } > ;
30
31
export type InfoWindowDefinition < InfoWindowOptions > = {
31
32
headerContent : string | null ;
32
33
content : string | null ;
@@ -36,6 +37,7 @@ export type InfoWindowDefinition<InfoWindowOptions> = {
36
37
rawOptions ?: InfoWindowOptions ;
37
38
extra : Record < string , unknown > ;
38
39
} ;
40
+ export type InfoWindowWithoutPositionDefinition < InfoWindowOptions > = Omit < InfoWindowDefinition < InfoWindowOptions > , 'position' > ;
39
41
export default abstract class < MapOptions , Map , MarkerOptions , Marker , InfoWindowOptions , InfoWindow , PolygonOptions , Polygon , PolylineOptions , Polyline > extends Controller < HTMLElement > {
40
42
static values : {
41
43
providerOptions : ObjectConstructor ;
@@ -55,50 +57,47 @@ export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindow
55
57
polylinesValue: Array < PolylineDefinition < PolylineOptions , InfoWindowOptions > > ;
56
58
optionsValue: MapOptions ;
57
59
protected map : Map ;
58
- protected markers : globalThis . Map < any , any > ;
60
+ protected markers : globalThis . Map < string , Marker > ;
61
+ protected polygons : globalThis . Map < string , Polygon > ;
62
+ protected polylines: globalThis . Map < string , Polyline > ;
59
63
protected infoWindows: Array < InfoWindow > ;
60
- protected polygons : globalThis . Map < any , any > ;
61
- protected polylines: globalThis . Map < any , any > ;
64
+ private isConnected ;
65
+ private createMarker ;
66
+ private createPolygon ;
67
+ private createPolyline ;
68
+ protected abstract dispatchEvent ( name : string , payload : Record < string , unknown > ) : void ;
62
69
connect ( ) : void ;
70
+ createInfoWindow ( { definition, element, } : {
71
+ definition : InfoWindowWithoutPositionDefinition < InfoWindowOptions > ;
72
+ element: Marker | Polygon | Polyline ;
73
+ } ) : InfoWindow ;
74
+ abstract centerValueChanged ( ) : void ;
75
+ abstract zoomValueChanged ( ) : void ;
76
+ markersValueChanged ( ) : void ;
77
+ polygonsValueChanged ( ) : void ;
78
+ polylinesValueChanged ( ) : void ;
63
79
protected abstract doCreateMap ( { center, zoom, options, } : {
64
80
center : Point | null ;
65
81
zoom: number | null ;
66
82
options: MapOptions ;
67
83
} ) : Map ;
68
- createMarker ( definition : MarkerDefinition < MarkerOptions , InfoWindowOptions > ) : Marker ;
69
- protected abstract removeMarker ( marker : Marker ) : void ;
70
- protected abstract doCreateMarker ( definition : MarkerDefinition < MarkerOptions , InfoWindowOptions > ) : Marker ;
71
- createPolygon ( definition : PolygonDefinition < PolygonOptions , InfoWindowOptions > ) : Polygon ;
72
- protected abstract removePolygon ( polygon : Polygon ) : void ;
73
- protected abstract doCreatePolygon ( definition : PolygonDefinition < PolygonOptions , InfoWindowOptions > ) : Polygon ;
74
- createPolyline ( definition : PolylineDefinition < PolylineOptions , InfoWindowOptions > ) : Polyline ;
75
- protected abstract removePolyline ( polyline : Polyline ) : void ;
76
- protected abstract doCreatePolyline ( definition : PolylineDefinition < PolylineOptions , InfoWindowOptions > ) : Polyline ;
77
- protected createInfoWindow ( { definition, element, } : {
78
- definition : MarkerDefinition < MarkerOptions , InfoWindowOptions > [ 'infoWindow' ] ;
79
- element: Marker ;
80
- } | {
81
- definition: PolygonDefinition < PolygonOptions , InfoWindowOptions > [ 'infoWindow' ] ;
82
- element: Polygon ;
83
- } | {
84
- definition: PolylineDefinition < PolylineOptions , InfoWindowOptions > [ 'infoWindow' ] ;
85
- element: Polyline ;
86
- } ) : InfoWindow ;
84
+ protected abstract doFitBoundsToMarkers ( ) : void ;
85
+ protected abstract doCreateMarker ( { definition, } : {
86
+ definition : MarkerDefinition < MarkerOptions , InfoWindowOptions > ;
87
+ } ) : Marker ;
88
+ protected abstract doRemoveMarker ( marker : Marker ) : void ;
89
+ protected abstract doCreatePolygon ( { definition, } : {
90
+ definition : PolygonDefinition < PolygonOptions , InfoWindowOptions > ;
91
+ } ) : Polygon ;
92
+ protected abstract doRemovePolygon ( polygon : Polygon ) : void ;
93
+ protected abstract doCreatePolyline ( { definition, } : {
94
+ definition : PolylineDefinition < PolylineOptions , InfoWindowOptions > ;
95
+ } ) : Polyline ;
96
+ protected abstract doRemovePolyline ( polyline : Polyline ) : void ;
87
97
protected abstract doCreateInfoWindow ( { definition, element, } : {
88
- definition : MarkerDefinition < MarkerOptions , InfoWindowOptions > [ 'infoWindow' ] ;
89
- element: Marker ;
90
- } | {
91
- definition: PolygonDefinition < PolygonOptions , InfoWindowOptions > [ 'infoWindow' ] ;
92
- element: Polygon ;
93
- } | {
94
- definition: PolylineDefinition < PolylineOptions , InfoWindowOptions > [ 'infoWindow' ] ;
95
- element: Polyline ;
98
+ definition : InfoWindowWithoutPositionDefinition < InfoWindowOptions > ;
99
+ element: Marker | Polygon | Polyline ;
96
100
} ) : InfoWindow ;
97
- protected abstract doFitBoundsToMarkers ( ) : void ;
98
- protected abstract dispatchEvent ( name : string , payload : Record < string , unknown > ) : void ;
99
- abstract centerValueChanged ( ) : void ;
100
- abstract zoomValueChanged ( ) : void ;
101
- markersValueChanged ( ) : void ;
102
- polygonsValueChanged ( ) : void ;
103
- polylinesValueChanged ( ) : void ;
101
+ private createDrawingFactory ;
102
+ private onDrawChanged ;
104
103
}
0 commit comments