UNPKG

5.92 kBTypeScriptView Raw
1declare namespace google.maps {
2 type DrawingMode = 'Point' | 'LineString' | 'Polygon';
3
4 class Data extends MVCObject {
5 constructor(options?: Data.DataOptions);
6 add(feature: Data.Feature | Data.FeatureOptions): Data.Feature;
7 addGeoJson(geoJson: object, options?: Data.GeoJsonOptions): Data.Feature[];
8 contains(feature: Data.Feature): boolean;
9 forEach(callback: (feature: Data.Feature) => void): void;
10 getControlPosition(): ControlPosition;
11 getControls(): DrawingMode[];
12 getDrawingMode(): DrawingMode | null;
13 getFeatureById(id: number | string): Data.Feature;
14 getMap(): Map;
15 getStyle(): Data.StylingFunction | Data.StyleOptions;
16 loadGeoJson(url: string, options?: Data.GeoJsonOptions, callback?: (features: Data.Feature[]) => void): void;
17 overrideStyle(feature: Data.Feature, style: Data.StyleOptions): void;
18 remove(feature: Data.Feature): void;
19 revertStyle(feature?: Data.Feature): void;
20 setControlPosition(controlPosition: ControlPosition): void;
21 setControls(controls: DrawingMode[] | null): void;
22 setDrawingMode(drawingMode: DrawingMode | null): void;
23 setMap(map: Map | null): void;
24 setStyle(style: Data.StylingFunction | Data.StyleOptions): void;
25 toGeoJson(callback: (feature: object) => void): void;
26 }
27
28 namespace Data {
29 interface DataOptions {
30 controlPosition?: ControlPosition;
31 controls?: DrawingMode[] | null;
32 drawingMode?: DrawingMode | null;
33 featureFactory?: (geometry: Geometry) => Feature;
34 map?: Map;
35 style?: StylingFunction | StyleOptions;
36 }
37
38 interface GeoJsonOptions {
39 idPropertyName?: string;
40 }
41
42 interface StyleOptions {
43 clickable?: boolean;
44 cursor?: string;
45 draggable?: boolean;
46 editable?: boolean;
47 fillColor?: string;
48 fillOpacity?: number;
49 // tslint:disable-next-line:no-unnecessary-qualifier
50 icon?: string | Icon | google.maps.Symbol;
51 shape?: MarkerShape;
52 strokeColor?: string;
53 strokeOpacity?: number;
54 strokeWeight?: number;
55 title?: string;
56 visible?: boolean;
57 zIndex?: number;
58 }
59
60 type StylingFunction = (feature: Feature) => StyleOptions;
61
62 class Feature {
63 constructor(options?: FeatureOptions);
64 forEachProperty(callback: (value: any, name: string) => void): void;
65 getGeometry(): Geometry;
66 getId(): number | string;
67 getProperty(name: string): any;
68 removeProperty(name: string): void;
69 setGeometry(newGeometry: Geometry | LatLng | LatLngLiteral): void;
70 setProperty(name: string, newValue: any): void;
71 toGeoJson(callback: (feature: object) => void): void;
72 }
73
74 interface FeatureOptions {
75 geometry?: Geometry | LatLng | LatLngLiteral;
76 id?: number | string;
77 properties?: object;
78 }
79
80 class Geometry {
81 getType(): string;
82 forEachLatLng(callback: (latLng: LatLng) => void): void;
83 }
84
85 class Point extends Geometry {
86 constructor(latLng: LatLng | LatLngLiteral);
87 get(): LatLng;
88 }
89
90 class MultiPoint extends Geometry {
91 constructor(elements: Array<LatLng | LatLngLiteral>);
92 getArray(): LatLng[];
93 getAt(n: number): LatLng;
94 getLength(): number;
95 }
96
97 class LineString extends Geometry {
98 constructor(elements: Array<LatLng | LatLngLiteral>);
99 getArray(): LatLng[];
100 getAt(n: number): LatLng;
101 getLength(): number;
102 }
103
104 class MultiLineString extends Geometry {
105 constructor(elements: Array<LineString | Array<LatLng | LatLngLiteral>>);
106 getArray(): LineString[];
107 getAt(n: number): LineString;
108 getLength(): number;
109 }
110
111 class LinearRing extends Geometry {
112 constructor(elements: Array<LatLng | LatLngLiteral>);
113 getArray(): LatLng[];
114 getAt(n: number): LatLng;
115 getLength(): number;
116 }
117
118 class Polygon extends Geometry {
119 constructor(elements: Array<LinearRing | Array<LatLng | LatLngLiteral>>);
120 getArray(): LinearRing[];
121 getAt(n: number): LinearRing;
122 getLength(): number;
123 }
124
125 class MultiPolygon extends Geometry {
126 constructor(elements: Array<Polygon | Array<LinearRing | Array<LatLng | LatLngLiteral>>>);
127 getArray(): Polygon[];
128 getAt(n: number): Polygon;
129 getLength(): number;
130 }
131
132 class GeometryCollection extends Geometry {
133 constructor(elements: Array<Geometry[] | LatLng[] | LatLngLiteral>);
134 getArray(): Geometry[];
135 getAt(n: number): Geometry;
136 getLength(): number;
137 }
138
139 // tslint:disable-next-line:no-unnecessary-qualifier
140 interface MouseEvent extends google.maps.MouseEvent {
141 feature: Feature;
142 }
143
144 interface AddFeatureEvent {
145 feature: Feature;
146 }
147
148 interface RemoveFeatureEvent {
149 feature: Feature;
150 }
151
152 interface SetGeometryEvent {
153 feature: Feature;
154 newGeometry: Geometry;
155 oldGeometry: Geometry;
156 }
157
158 interface SetPropertyEvent {
159 feature: Feature;
160 name: string;
161 newValue: any;
162 oldValue: any;
163 }
164
165 interface RemovePropertyEvent {
166 feature: Feature;
167 name: string;
168 oldValue: any;
169 }
170 }
171}