UNPKG

7.99 kBTypeScriptView Raw
1/// <reference types="googlemaps" />
2import { EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
3import { DataLayerManager } from './../services/managers/data-layer-manager';
4/**
5 * AgmDataLayer enables the user to add data layers to the map.
6 *
7 * ### Example
8 * ```typescript
9 * import { Component } from 'angular2/core';
10 * import { AgmMap, AgmDataLayer } from
11 * 'angular-google-maps/core';
12 *
13 * @Component({
14 * selector: 'my-map-cmp',
15 * directives: [AgmMap, AgmDataLayer],
16 * styles: [`
17 * .agm-container {
18 * height: 300px;
19 * }
20 * `],
21 * template: `
22 * <agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
23 * <agm-data-layer [geoJson]="geoJsonObject" (layerClick)="clicked($event)" [style]="styleFunc">
24 * </agm-data-layer>
25 * </agm-map>
26 * `
27 * })
28 * export class MyMapCmp {
29 * lat: number = -25.274449;
30 * lng: number = 133.775060;
31 * zoom: number = 5;
32 *
33 * clicked(clickEvent) {
34 * console.log(clickEvent);
35 * }
36 *
37 * styleFunc(feature) {
38 * return ({
39 * clickable: false,
40 * fillColor: feature.getProperty('color'),
41 * strokeWeight: 1
42 * });
43 * }
44 *
45 * geoJsonObject: Object = {
46 * "type": "FeatureCollection",
47 * "features": [
48 * {
49 * "type": "Feature",
50 * "properties": {
51 * "letter": "G",
52 * "color": "blue",
53 * "rank": "7",
54 * "ascii": "71"
55 * },
56 * "geometry": {
57 * "type": "Polygon",
58 * "coordinates": [
59 * [
60 * [123.61, -22.14], [122.38, -21.73], [121.06, -21.69], [119.66, -22.22], [119.00, -23.40],
61 * [118.65, -24.76], [118.43, -26.07], [118.78, -27.56], [119.22, -28.57], [120.23, -29.49],
62 * [121.77, -29.87], [123.57, -29.64], [124.45, -29.03], [124.71, -27.95], [124.80, -26.70],
63 * [124.80, -25.60], [123.61, -25.64], [122.56, -25.64], [121.72, -25.72], [121.81, -26.62],
64 * [121.86, -26.98], [122.60, -26.90], [123.57, -27.05], [123.57, -27.68], [123.35, -28.18],
65 * [122.51, -28.38], [121.77, -28.26], [121.02, -27.91], [120.49, -27.21], [120.14, -26.50],
66 * [120.10, -25.64], [120.27, -24.52], [120.67, -23.68], [121.72, -23.32], [122.43, -23.48],
67 * [123.04, -24.04], [124.54, -24.28], [124.58, -23.20], [123.61, -22.14]
68 * ]
69 * ]
70 * }
71 * },
72 * {
73 * "type": "Feature",
74 * "properties": {
75 * "letter": "o",
76 * "color": "red",
77 * "rank": "15",
78 * "ascii": "111"
79 * },
80 * "geometry": {
81 * "type": "Polygon",
82 * "coordinates": [
83 * [
84 * [128.84, -25.76], [128.18, -25.60], [127.96, -25.52], [127.88, -25.52], [127.70, -25.60],
85 * [127.26, -25.79], [126.60, -26.11], [126.16, -26.78], [126.12, -27.68], [126.21, -28.42],
86 * [126.69, -29.49], [127.74, -29.80], [128.80, -29.72], [129.41, -29.03], [129.72, -27.95],
87 * [129.68, -27.21], [129.33, -26.23], [128.84, -25.76]
88 * ],
89 * [
90 * [128.45, -27.44], [128.32, -26.94], [127.70, -26.82], [127.35, -27.05], [127.17, -27.80],
91 * [127.57, -28.22], [128.10, -28.42], [128.49, -27.80], [128.45, -27.44]
92 * ]
93 * ]
94 * }
95 * },
96 * {
97 * "type": "Feature",
98 * "properties": {
99 * "letter": "o",
100 * "color": "yellow",
101 * "rank": "15",
102 * "ascii": "111"
103 * },
104 * "geometry": {
105 * "type": "Polygon",
106 * "coordinates": [
107 * [
108 * [131.87, -25.76], [131.35, -26.07], [130.95, -26.78], [130.82, -27.64], [130.86, -28.53],
109 * [131.26, -29.22], [131.92, -29.76], [132.45, -29.87], [133.06, -29.76], [133.72, -29.34],
110 * [134.07, -28.80], [134.20, -27.91], [134.07, -27.21], [133.81, -26.31], [133.37, -25.83],
111 * [132.71, -25.64], [131.87, -25.76]
112 * ],
113 * [
114 * [133.15, -27.17], [132.71, -26.86], [132.09, -26.90], [131.74, -27.56], [131.79, -28.26],
115 * [132.36, -28.45], [132.93, -28.34], [133.15, -27.76], [133.15, -27.17]
116 * ]
117 * ]
118 * }
119 * },
120 * {
121 * "type": "Feature",
122 * "properties": {
123 * "letter": "g",
124 * "color": "blue",
125 * "rank": "7",
126 * "ascii": "103"
127 * },
128 * "geometry": {
129 * "type": "Polygon",
130 * "coordinates": [
131 * [
132 * [138.12, -25.04], [136.84, -25.16], [135.96, -25.36], [135.26, -25.99], [135, -26.90],
133 * [135.04, -27.91], [135.26, -28.88], [136.05, -29.45], [137.02, -29.49], [137.81, -29.49],
134 * [137.94, -29.99], [137.90, -31.20], [137.85, -32.24], [136.88, -32.69], [136.45, -32.36],
135 * [136.27, -31.80], [134.95, -31.84], [135.17, -32.99], [135.52, -33.43], [136.14, -33.76],
136 * [137.06, -33.83], [138.12, -33.65], [138.86, -33.21], [139.30, -32.28], [139.30, -31.24],
137 * [139.30, -30.14], [139.21, -28.96], [139.17, -28.22], [139.08, -27.41], [139.08, -26.47],
138 * [138.99, -25.40], [138.73, -25.00], [138.12, -25.04]
139 * ],
140 * [
141 * [137.50, -26.54], [136.97, -26.47], [136.49, -26.58], [136.31, -27.13], [136.31, -27.72],
142 * [136.58, -27.99], [137.50, -28.03], [137.68, -27.68], [137.59, -26.78], [137.50, -26.54]
143 * ]
144 * ]
145 * }
146 * },
147 * {
148 * "type": "Feature",
149 * "properties": {
150 * "letter": "l",
151 * "color": "green",
152 * "rank": "12",
153 * "ascii": "108"
154 * },
155 * "geometry": {
156 * "type": "Polygon",
157 * "coordinates": [
158 * [
159 * [140.14, -21.04], [140.31, -29.42], [141.67, -29.49], [141.59, -20.92], [140.14, -21.04]
160 * ]
161 * ]
162 * }
163 * },
164 * {
165 * "type": "Feature",
166 * "properties": {
167 * "letter": "e",
168 * "color": "red",
169 * "rank": "5",
170 * "ascii": "101"
171 * },
172 * "geometry": {
173 * "type": "Polygon",
174 * "coordinates": [
175 * [
176 * [144.14, -27.41], [145.67, -27.52], [146.86, -27.09], [146.82, -25.64], [146.25, -25.04],
177 * [145.45, -24.68], [144.66, -24.60], [144.09, -24.76], [143.43, -25.08], [142.99, -25.40],
178 * [142.64, -26.03], [142.64, -27.05], [142.64, -28.26], [143.30, -29.11], [144.18, -29.57],
179 * [145.41, -29.64], [146.46, -29.19], [146.64, -28.72], [146.82, -28.14], [144.84, -28.42],
180 * [144.31, -28.26], [144.14, -27.41]
181 * ],
182 * [
183 * [144.18, -26.39], [144.53, -26.58], [145.19, -26.62], [145.72, -26.35], [145.81, -25.91],
184 * [145.41, -25.68], [144.97, -25.68], [144.49, -25.64], [144, -25.99], [144.18, -26.39]
185 * ]
186 * ]
187 * }
188 * }
189 * ]
190 * };
191 * }
192 * ```
193 */
194export declare class AgmDataLayer implements OnInit, OnDestroy, OnChanges {
195 private _manager;
196 private static _dataOptionsAttributes;
197 private _addedToManager;
198 private _id;
199 private _subscriptions;
200 /**
201 * This event is fired when a feature in the layer is clicked.
202 */
203 layerClick: EventEmitter<google.maps.Data.MouseEvent>;
204 /**
205 * The geoJson to be displayed
206 */
207 geoJson: object | string | null;
208 /**
209 * The layer's style function.
210 */
211 style: (param: google.maps.Data.Feature) => google.maps.Data.StyleOptions;
212 constructor(_manager: DataLayerManager);
213 ngOnInit(): void;
214 private _addEventListeners;
215 /** @internal */
216 id(): string;
217 /** @internal */
218 toString(): string;
219 /** @internal */
220 ngOnDestroy(): void;
221 /** @internal */
222 ngOnChanges(changes: SimpleChanges): void;
223}