UNPKG

11 kBTypeScriptView Raw
1/// <reference types="googlemaps" />
2import { AfterContentInit, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, QueryList, SimpleChanges } from '@angular/core';
3import { FitBoundsService } from '../services/fit-bounds';
4import { GoogleMapsAPIWrapper } from '../services/google-maps-api-wrapper';
5export declare type ControlPosition = keyof typeof google.maps.ControlPosition;
6export declare abstract class AgmMapControl {
7 position: ControlPosition;
8 abstract getOptions(): Partial<google.maps.MapOptions>;
9}
10export declare class AgmFullscreenControl extends AgmMapControl {
11 getOptions(): Partial<google.maps.MapOptions>;
12}
13export declare class AgmMapTypeControl extends AgmMapControl {
14 mapTypeIds: (keyof typeof google.maps.MapTypeId)[];
15 style: keyof typeof google.maps.MapTypeControlStyle;
16 getOptions(): Partial<google.maps.MapOptions>;
17}
18export declare class AgmPanControl extends AgmMapControl {
19 getOptions(): Partial<google.maps.MapOptions>;
20}
21export declare class AgmRotateControl extends AgmMapControl {
22 getOptions(): Partial<google.maps.MapOptions>;
23}
24export declare class AgmScaleControl extends AgmMapControl {
25 getOptions(): Partial<google.maps.MapOptions>;
26}
27export declare class AgmStreetViewControl extends AgmMapControl {
28 getOptions(): Partial<google.maps.MapOptions>;
29}
30export declare class AgmZoomControl extends AgmMapControl {
31 style: keyof typeof google.maps.ZoomControlStyle;
32 getOptions(): Partial<google.maps.MapOptions>;
33}
34/**
35 * AgmMap renders a Google Map.
36 * **Important note**: To be able see a map in the browser, you have to define a height for the
37 * element `agm-map`.
38 *
39 * ### Example
40 * ```typescript
41 * import { Component } from '@angular/core';
42 *
43 * @Component({
44 * selector: 'my-map-cmp',
45 * styles: [`
46 * agm-map {
47 * height: 300px;
48 * }
49 * `],
50 * template: `
51 * <agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
52 * </agm-map>
53 * `
54 * })
55 * ```
56 */
57export declare class AgmMap implements OnChanges, AfterContentInit, OnDestroy {
58 private _elem;
59 private _mapsWrapper;
60 private _platformId;
61 protected _fitBoundsService: FitBoundsService;
62 private _zone;
63 /**
64 * The longitude that defines the center of the map.
65 */
66 longitude: number;
67 /**
68 * The latitude that defines the center of the map.
69 */
70 latitude: number;
71 /**
72 * The zoom level of the map. The default zoom level is 8.
73 */
74 zoom: number;
75 /**
76 * The minimal zoom level of the map allowed. When not provided, no restrictions to the zoom level
77 * are enforced.
78 */
79 minZoom: number;
80 /**
81 * The maximal zoom level of the map allowed. When not provided, no restrictions to the zoom level
82 * are enforced.
83 */
84 maxZoom: number;
85 /**
86 * The control size for the default map controls. Only governs the controls made by the Maps API itself
87 */
88 controlSize: number;
89 /**
90 * Enables/disables if map is draggable.
91 */
92 draggable: boolean;
93 /**
94 * Enables/disables zoom and center on double click. Enabled by default.
95 */
96 disableDoubleClickZoom: boolean;
97 /**
98 * Enables/disables all default UI of the Google map. Please note: When the map is created, this
99 * value cannot get updated.
100 */
101 disableDefaultUI: boolean;
102 /**
103 * If false, disables scrollwheel zooming on the map. The scrollwheel is enabled by default.
104 */
105 scrollwheel: boolean;
106 /**
107 * Color used for the background of the Map div. This color will be visible when tiles have not
108 * yet loaded as the user pans. This option can only be set when the map is initialized.
109 */
110 backgroundColor: string;
111 /**
112 * The name or url of the cursor to display when mousing over a draggable map. This property uses
113 * the css * cursor attribute to change the icon. As with the css property, you must specify at
114 * least one fallback cursor that is not a URL. For example:
115 * [draggableCursor]="'url(http://www.example.com/icon.png), auto;'"
116 */
117 draggableCursor: string;
118 /**
119 * The name or url of the cursor to display when the map is being dragged. This property uses the
120 * css cursor attribute to change the icon. As with the css property, you must specify at least
121 * one fallback cursor that is not a URL. For example:
122 * [draggingCursor]="'url(http://www.example.com/icon.png), auto;'"
123 */
124 draggingCursor: string;
125 /**
126 * If false, prevents the map from being controlled by the keyboard. Keyboard shortcuts are
127 * enabled by default.
128 */
129 keyboardShortcuts: boolean;
130 /**
131 * Styles to apply to each of the default map types. Note that for Satellite/Hybrid and Terrain
132 * modes, these styles will only apply to labels and geometry.
133 */
134 styles: google.maps.MapTypeStyle[];
135 /**
136 * When true and the latitude and/or longitude values changes, the Google Maps panTo method is
137 * used to
138 * center the map. See: https://developers.google.com/maps/documentation/javascript/reference#Map
139 */
140 usePanning: boolean;
141 /**
142 * Sets the viewport to contain the given bounds.
143 * If this option to `true`, the bounds get automatically computed from all elements that use the {@link AgmFitBounds} directive.
144 */
145 fitBounds: google.maps.LatLngBoundsLiteral | google.maps.LatLngBounds | boolean;
146 /**
147 * Padding amount for the bounds.
148 */
149 fitBoundsPadding: number | google.maps.Padding;
150 /**
151 * The map mapTypeId. Defaults to 'roadmap'.
152 */
153 mapTypeId: keyof typeof google.maps.MapTypeId;
154 /**
155 * When false, map icons are not clickable. A map icon represents a point of interest,
156 * also known as a POI. By default map icons are clickable.
157 */
158 clickableIcons: boolean;
159 /**
160 * A map icon represents a point of interest, also known as a POI.
161 * When map icons are clickable by default, an info window is displayed.
162 * When this property is set to false, the info window will not be shown but the click event
163 * will still fire
164 */
165 showDefaultInfoWindow: boolean;
166 /**
167 * This setting controls how gestures on the map are handled.
168 * Allowed values:
169 * - 'cooperative' (Two-finger touch gestures pan and zoom the map. One-finger touch gestures are not handled by the map.)
170 * - 'greedy' (All touch gestures pan or zoom the map.)
171 * - 'none' (The map cannot be panned or zoomed by user gestures.)
172 * - 'auto' [default] (Gesture handling is either cooperative or greedy, depending on whether the page is scrollable or not.
173 */
174 gestureHandling: google.maps.GestureHandlingOptions;
175 /**
176 * Controls the automatic switching behavior for the angle of incidence of
177 * the map. The only allowed values are 0 and 45. The value 0 causes the map
178 * to always use a 0° overhead view regardless of the zoom level and
179 * viewport. The value 45 causes the tilt angle to automatically switch to
180 * 45 whenever 45° imagery is available for the current zoom level and
181 * viewport, and switch back to 0 whenever 45° imagery is not available
182 * (this is the default behavior). 45° imagery is only available for
183 * satellite and hybrid map types, within some locations, and at some zoom
184 * levels. Note: getTilt returns the current tilt angle, not the value
185 * specified by this option. Because getTilt and this option refer to
186 * different things, do not bind() the tilt property; doing so may yield
187 * unpredictable effects. (Default of AGM is 0 (disabled). Enable it with value 45.)
188 */
189 tilt: number;
190 /**
191 * Options for restricting the bounds of the map.
192 * User cannot pan or zoom away from restricted area.
193 */
194 restriction: google.maps.MapRestriction;
195 /**
196 * Map option attributes that can change over time
197 */
198 private static _mapOptionsAttributes;
199 private _observableSubscriptions;
200 private _fitBoundsSubscription;
201 /**
202 * This event emitter gets emitted when the user clicks on the map (but not when they click on a
203 * marker or infoWindow).
204 */
205 mapClick: EventEmitter<google.maps.MouseEvent | google.maps.IconMouseEvent>;
206 /**
207 * This event emitter gets emitted when the user right-clicks on the map (but not when they click
208 * on a marker or infoWindow).
209 */
210 mapRightClick: EventEmitter<google.maps.MouseEvent>;
211 /**
212 * This event emitter gets emitted when the user double-clicks on the map (but not when they click
213 * on a marker or infoWindow).
214 */
215 mapDblClick: EventEmitter<google.maps.MouseEvent>;
216 /**
217 * This event emitter is fired when the map center changes.
218 */
219 centerChange: EventEmitter<google.maps.LatLngLiteral>;
220 /**
221 * This event is fired when the viewport bounds have changed.
222 */
223 boundsChange: EventEmitter<google.maps.LatLngBounds>;
224 /**
225 * This event is fired when the mapTypeId property changes.
226 */
227 mapTypeIdChange: EventEmitter<google.maps.MapTypeId>;
228 /**
229 * This event is fired when the map becomes idle after panning or zooming.
230 */
231 idle: EventEmitter<void>;
232 /**
233 * This event is fired when the zoom level has changed.
234 */
235 zoomChange: EventEmitter<number>;
236 /**
237 * This event is fired when the google map is fully initialized.
238 * You get the google.maps.Map instance as a result of this EventEmitter.
239 */
240 mapReady: EventEmitter<any>;
241 /**
242 * This event is fired when the visible tiles have finished loading.
243 */
244 tilesLoaded: EventEmitter<void>;
245 mapControls: QueryList<AgmMapControl>;
246 constructor(_elem: ElementRef, _mapsWrapper: GoogleMapsAPIWrapper, _platformId: Object, _fitBoundsService: FitBoundsService, _zone: NgZone);
247 /** @internal */
248 ngAfterContentInit(): void;
249 private _initMapInstance;
250 /** @internal */
251 ngOnDestroy(): void;
252 ngOnChanges(changes: SimpleChanges): void;
253 private _updateMapOptionsChanges;
254 /**
255 * Triggers a resize event on the google map instance.
256 * When recenter is true, the of the google map gets called with the current lat/lng values or fitBounds value to recenter the map.
257 * Returns a promise that gets resolved after the event was triggered.
258 */
259 triggerResize(recenter?: boolean): Promise<void>;
260 private _updatePosition;
261 private _setCenter;
262 private _fitBounds;
263 private _subscribeToFitBoundsUpdates;
264 protected _updateBounds(bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral, padding?: number | google.maps.Padding): void;
265 private _isLatLngBoundsLiteral;
266 private _handleMapCenterChange;
267 private _handleBoundsChange;
268 private _handleMapTypeIdChange;
269 private _handleMapZoomChange;
270 private _handleIdleEvent;
271 private _handleTilesLoadedEvent;
272 private _handleMapMouseEvents;
273 _handleControlChange(): void;
274 _setControls(): void;
275}