diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index fee5b298fd..3d875b2b53 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -91,100 +91,146 @@ export class LatLngBounds implements ILatLngBounds { getCenter(): LatLng { return; } } -export interface GoogleMapOptions { +export interface GoogleMapControlOptions { /** - * MapType + * Turns the compass on or off. */ - mapType?: MapType; + compass?: boolean; - controls?: { + /** + * Turns the myLocation button on or off. If turns on this button, the application displays a permission dialog to obtain the geolocation data. + */ + myLocationButton?: boolean; - /** - * Turns the compass on or off. - */ - compass?: boolean; + /** + * Turns the myLocation control(blue dot) on or off. If turns on this control, the application displays a permission dialog to obtain the geolocation data. + */ + myLocation?: boolean; - /** - * Turns the myLocation picker on or off. If turns on this button, the application displays a permission dialog to obtain the geolocation data. - */ - myLocationButton?: boolean; + /** + * Turns the indoor picker on or off. + */ + indoorPicker?: boolean; - /** - * Turns the indoor picker on or off. - */ - indoorPicker?: boolean; + /** + * **Android** + * Turns the map toolbar on or off. + */ + mapToolbar?: boolean; - /** - * Turns the map toolbar on or off. This option is for Android only. - */ - mapToolbar?: boolean; + /** + * **Android** + * Turns the zoom controller on or off. + */ + zoom?: boolean; - /** - * Turns the zoom controller on or off. This option is for Android only. - */ - zoom?: boolean; - }; + /** + * Accept extra properties for future updates + */ + [key: string]: any; +} - gestures?: { +export interface GoogleMapGestureOptions { - /** - * Set false to disable the scroll gesture (default: true) - */ - scroll?: boolean; + /** + * Set false to disable the scroll gesture (default: true) + */ + scroll?: boolean; - /** - * Set false to disable the tilt gesture (default: true) - */ - tilt?: boolean; + /** + * Set false to disable the tilt gesture (default: true) + */ + tilt?: boolean; - /** - * Set false to disable the zoom gesture (default: true) - */ - zoom?: boolean; + /** + * Set false to disable the zoom gesture (default: true) + */ + zoom?: boolean; - /** - * Set false to disable the rotate gesture (default: true) - */ - rotate?: boolean; - }; + /** + * Set false to disable the rotate gesture (default: true) + */ + rotate?: boolean; /** - * Map styles + * Accept extra properties for future updates + */ + [key: string]: any; +} + +export interface GoogleMapZoomOptions { + minZoom?: number; + maxZoom?: number; +} + +export interface GoogleMapPaddingOptions { + left?: number; + top?: number; + bottom?: number; + right?: number; +} + +export interface GoogleMapPreferenceOptions { + + /** + * Minimum and maximum zoom levels for zooming gestures. + */ + zoom?: GoogleMapZoomOptions; + + /** + * Paddings of controls. + */ + padding?: GoogleMapPaddingOptions; + + /** + * Turns the 3D buildings layer on or off. + */ + building?: boolean; + + /** + * Accept extra properties for future updates + */ + [key: string]: any; +} + +export interface GoogleMapOptions { + + /** + * mapType [options] + */ + mapType?: MapType; + + /** + * controls [options] + */ + controls?: GoogleMapControlOptions; + + /** + * gestures [options] + */ + gestures?: GoogleMapGestureOptions; + + /** + * Map styles [options] * @ref https://developers.google.com/maps/documentation/javascript/style-reference */ styles?: any[]; /** - * Initial camera position + * Initial camera position [options] */ camera?: CameraPosition; - preferences?: { - - /** - * Minimum and maximum zoom levels for zooming gestures. - */ - zoom?: { - minZoom?: number; - maxZoom?: number; - }; - - /** - * Paddings of controls. - */ - padding?: { - left?: number; - top?: number; - bottom?: number; - right?: number; - }; - - /** - * Turns the 3D buildings layer on or off. - */ - building?: boolean - }; + /** + * preferences [options] + */ + preferences?: GoogleMapPreferenceOptions; + + /** + * Accept extra properties for future updates + */ + [key: string]: any; } export interface CameraPosition { @@ -679,6 +725,39 @@ export interface TileOverlayOptions { [key: string]: any; } +export interface ToDataUrlOptions { + /** + * True if you want get high quality map snapshot + */ + uncompress?: boolean; +} + + +/** + * Options for map.addKmlOverlay() method + */ +export interface KmlOverlayOptions { + /* + * The url or file path of KML file. KMZ format is not supported. + */ + url: string; + + /* + * Do not fire the KML_CLICK event if false. Default is true. + */ + clickable?: boolean; + + /* + * Do not display the default infoWindow if true. Default is false. + */ + suppressInfoWindows?: boolean; + + /** + * Accept own properties for future update + */ + [key: string]: any; +} + /** * @hidden @@ -686,12 +765,41 @@ export interface TileOverlayOptions { export class VisibleRegion implements ILatLngBounds { private _objectInstance: any; + /** + * The northeast of the bounds that contains the farLeft, farRight, nearLeft and nearRight. + * Since the map view is able to rotate, the farRight is not the same as the northeast. + */ @InstanceProperty northeast: ILatLng; + + /** + * The southwest of the bounds that contains the farLeft, farRight, nearLeft and nearRight. + * Since the map view is able to rotate, the nearLeft is not the same as the southwest. + */ @InstanceProperty southwest: ILatLng; + + /** + * The nearRight indicates the lat/lng of the top-left of the map view. + */ @InstanceProperty farLeft: ILatLng; + + /** + * The nearRight indicates the lat/lng of the top-right of the map view. + */ @InstanceProperty farRight: ILatLng; + + /** + * The nearRight indicates the lat/lng of the bottom-left of the map view. + */ @InstanceProperty nearLeft: ILatLng; + + /** + * The nearRight indicates the lat/lng of the bottom-right of the map view. + */ @InstanceProperty nearRight: ILatLng; + + /** + * constant value : `VisibleRegion` + */ @InstanceProperty type: string; constructor(southwest: LatLngBounds, northeast: LatLngBounds, farLeft: ILatLng, farRight: ILatLng, nearLeft: ILatLng, nearRight: ILatLng) { @@ -729,9 +837,10 @@ export class VisibleRegion implements ILatLngBounds { */ export const GoogleMapsEvent = { MAP_READY: 'map_ready', - MAP_LOADED: 'map_loaded', MAP_CLICK: 'map_click', MAP_LONG_CLICK: 'map_long_click', + POI_CLICK: 'poi_click', + MY_LOCATION_CLICK: 'my_location_click', MY_LOCATION_BUTTON_CLICK: 'my_location_button_click', INDOOR_BUILDING_FOCUSED: 'indoor_building_focused', INDOOR_LEVEL_ACTIVATED: 'indoor_level_activated', @@ -747,14 +856,14 @@ export const GoogleMapsEvent = { INFO_LONG_CLICK: 'info_long_click', INFO_CLOSE: 'info_close', INFO_OPEN: 'info_open', - CLUSTER_CLICK: 'cluster_click', MARKER_CLICK: 'marker_click', MARKER_DRAG: 'marker_drag', MARKER_DRAG_START: 'marker_drag_start', MARKER_DRAG_END: 'marker_drag_end', MAP_DRAG: 'map_drag', MAP_DRAG_START: 'map_drag_start', - MAP_DRAG_END: 'map_drag_end' + MAP_DRAG_END: 'map_drag_end', + KML_CLICK: 'kml_click' }; /** @@ -801,7 +910,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { * }) * export class HomePage { * map: GoogleMap; - * constructor(private googleMaps: GoogleMaps) { } + * constructor() { } * * ionViewDidLoad() { * this.loadMap(); @@ -820,7 +929,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { * } * }; * - * this.map = this.googleMaps.create('map_canvas', mapOptions); + * this.map = GoogleMaps.create('map_canvas', mapOptions); * * // Wait the MAP_READY before using any methods. * this.map.one(GoogleMapsEvent.MAP_READY) @@ -865,6 +974,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { * Polygon * Polyline * Spherical + * KmlOverlay * Poly * TileOverlay * BaseClass @@ -886,6 +996,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { * PolygonOptions * PolylineOptions * TileOverlayOptions + * KmlOverlayOptions * VisibleRegion */ @Plugin({ @@ -893,6 +1004,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = { pluginRef: 'plugin.google.maps', plugin: 'cordova-plugin-googlemaps', repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps', + document: 'https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.0.0/README.md', install: 'ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"', installVariables: ['API_KEY_FOR_ANDROID', 'API_KEY_FOR_IOS'], platforms: ['Android', 'iOS'] @@ -903,7 +1015,7 @@ export class GoogleMaps extends IonicNativePlugin { /** * Creates a new GoogleMap instance * @param element {string | HTMLElement} Element ID or reference to attach the map to - * @param options {any} Options + * @param options {GoogleMapOptions} [options] Options * @return {GoogleMap} */ static create(element: string | HTMLElement | GoogleMapOptions, options?: GoogleMapOptions): GoogleMap { @@ -947,7 +1059,7 @@ export class BaseClass { /** * Adds an event listener. - * + * @param eventName {string} event name you want to observe. * @return {Observable} */ @InstanceCheck({ observable: true }) @@ -981,7 +1093,7 @@ export class BaseClass { /** * Adds an event listener that works once. - * + * @param eventName {string} event name you want to observe. * @return {Promise} */ @InstanceCheck() @@ -1015,32 +1127,33 @@ export class BaseClass { /** * Gets a value - * @param key + * @param key {any} */ @CordovaInstance({ sync: true }) get(key: string): any { return; } /** * Sets a value - * @param key - * @param value + * @param key {string} The key name for the value. `(key)_changed` will be fired when you set value through this method. + * @param value {any} + * @param noNotify {boolean} [options] True if you want to prevent firing the `(key)_changed` event. */ @CordovaInstance({ sync: true }) set(key: string, value: any, noNotify?: boolean): void { } /** * Bind a key to another object - * @param key {string} - * @param target {any} - * @param targetKey? {string} - * @param noNotify? {boolean} + * @param key {string} The property name you want to observe. + * @param target {any} The target object you want to observe. + * @param targetKey? {string} [options] The property name you want to observe. If you omit this, the `key` argument is used. + * @param noNotify? {boolean} [options] True if you want to prevent `(key)_changed` event when you bind first time, because the internal status is changed from `undefined` to something. */ @CordovaInstance({ sync: true }) bindTo(key: string, target: any, targetKey?: string, noNotify?: boolean): void { } /** - * Listen to a map event. - * + * Alias of `addEventListener` + * @param key {string} The property name you want to observe. * @return {Observable} */ @InstanceCheck({ observable: true }) @@ -1073,8 +1186,8 @@ export class BaseClass { } /** - * Listen to a map event only once. - * + * Alias of `addEventListenerOnce` + * @param key {string} The property name you want to observe. * @return {Promise} */ @InstanceCheck() @@ -1114,6 +1227,8 @@ export class BaseClass { /** * Dispatch event. + * @param eventName {string} Event name + * @param parameters {any} [options] The data you want to pass to event listerners. */ @CordovaInstance({ sync: true }) trigger(eventName: string, ...parameters: any[]): void {} @@ -1130,6 +1245,32 @@ export class BaseClass { } this._objectInstance.remove(); } + + /** + * Remove event listener(s) + * The `removeEventListener()` has three usages: + * - removeEventListener("eventName", listenerFunction); + * This removes one particular event listener + * - removeEventListener("eventName"); + * This removes the event listeners that added for the event name. + * - removeEventListener(); + * This removes all listeners. + * + * @param eventName {string} [options] Event name + * @param listener {Function} [options] Event listener + */ + @CordovaInstance({ sync: true }) + removeEventListener(eventName?: string, listener?: (...parameters: any[]) => void): void {} + + /** + * Alias of `removeEventListener` + * + * @param eventName {string} [options] Event name + * @param listener {Function} [options] Event listener + */ + @CordovaInstance({ sync: true }) + off(eventName?: string, listener?: (...parameters: any[]) => void): void {} + } /** @@ -1155,7 +1296,7 @@ export class BaseArrayClass extends BaseClass { /** * Removes all elements from the array. - * @param noNotify? {boolean} Set true to prevent remove_at events. + * @param noNotify? {boolean} [options] Set true to prevent remove_at events. */ @CordovaInstance({ sync: true }) empty(noNotify?: boolean): void {} @@ -1163,7 +1304,6 @@ export class BaseArrayClass extends BaseClass { /** * Iterate over each element, calling the provided callback. * @param fn {Function} - * @param callback? {Function} */ @CordovaInstance({ sync: true }) forEach(fn: (element: T, index?: number) => void): void {} @@ -1176,7 +1316,7 @@ export class BaseArrayClass extends BaseClass { @CordovaCheck() forEachAsync(fn: ((element: T, callback: () => void) => void)): Promise { return new Promise((resolve) => { - this._objectInstance.forEach(fn, resolve); + this._objectInstance.forEachAsync(fn, resolve); }); } @@ -1184,7 +1324,6 @@ export class BaseArrayClass extends BaseClass { * Iterate over each element, then return a new value. * Then you can get the results of each callback. * @param fn {Function} - * @param callback? {Function} * @return {Array} returns a new array with the results */ @CordovaInstance({ sync: true }) @@ -1194,20 +1333,32 @@ export class BaseArrayClass extends BaseClass { * Iterate over each element, calling the provided callback. * Then you can get the results of each callback. * @param fn {Function} - * @param callback? {Function} + * @param callback {Function} * @return {Promise} returns a new array with the results */ @CordovaCheck() mapAsync(fn: ((element: T, callback: (newElement: any) => void) => void)): Promise { return new Promise((resolve) => { - this._objectInstance.map(fn, resolve); + this._objectInstance.mapAsync(fn, resolve); + }); + } + + /** + * Same as `mapAsync`, but keep the execution order + * @param fn {Function} + * @param callback {Function} + * @return {Promise} returns a new array with the results + */ + @CordovaCheck() + mapSeries(fn: ((element: T, callback: (newElement: any) => void) => void)): Promise { + return new Promise((resolve) => { + this._objectInstance.mapSeries(fn, resolve); }); } /** * The filter() method creates a new array with all elements that pass the test implemented by the provided function. * @param fn {Function} - * @param callback? {Function} * @return {Array} returns a new filtered array */ @CordovaInstance({ sync: true }) @@ -1216,13 +1367,13 @@ export class BaseArrayClass extends BaseClass { /** * The filterAsync() method creates a new array with all elements that pass the test implemented by the provided function. * @param fn {Function} - * @param callback? {Function} + * @param callback {Function} * @return {Promise} returns a new filtered array */ @CordovaCheck() filterAsync(fn: (element: T, callback: (result: boolean) => void) => void): Promise { return new Promise((resolve) => { - this._objectInstance.filter(fn, resolve); + this._objectInstance.filterAsync(fn, resolve); }); } @@ -1272,7 +1423,7 @@ export class BaseArrayClass extends BaseClass { * Inserts an element at the specified index. * @param index {number} * @param element {Object} - * @param noNotify? {boolean} Set true to prevent insert_at events. + * @param noNotify? {boolean} [options] Set true to prevent insert_at events. * @return {Object} */ @CordovaInstance({ sync: true }) @@ -1280,7 +1431,7 @@ export class BaseArrayClass extends BaseClass { /** * Removes the last element of the array and returns that element. - * @param noNotify? {boolean} Set true to prevent remove_at events. + * @param noNotify? {boolean} [options] Set true to prevent remove_at events. * @return {Object} */ @CordovaInstance({ sync: true }) @@ -1297,7 +1448,7 @@ export class BaseArrayClass extends BaseClass { /** * Removes an element from the specified index. * @param index {number} - * @param noNotify? {boolean} Set true to prevent insert_at events. + * @param noNotify? {boolean} [options] Set true to prevent remove_at events. */ @CordovaInstance({ sync: true }) removeAt(index: number, noNotify?: boolean): void {} @@ -1306,7 +1457,7 @@ export class BaseArrayClass extends BaseClass { * Sets an element at the specified index. * @param index {number} * @param element {object} - * @param noNotify? {boolean} Set true to prevent set_at events. + * @param noNotify? {boolean} [options] Set true to prevent set_at events. */ @CordovaInstance({ sync: true }) setAt(index: number, element: T, noNotify?: boolean): void {} @@ -1337,7 +1488,7 @@ export class Circle extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Change the center position. @@ -1578,6 +1729,28 @@ export class Geocoder { } } +/** + * @hidden + */ +@Plugin({ + pluginName: 'GoogleMaps', + pluginRef: 'plugin.google.maps.LocationService', + plugin: 'cordova-plugin-googlemaps', + repo: '' +}) +export class LocationService { + + /** + * Get the current device location without map + * @return {Promise} + */ + static getMyLocation(options?: MyLocationOptions): Promise { + return new Promise((resolve, reject) => { + GoogleMaps.getPlugin().LocationService.getMyLocation(options, resolve); + }); + } +} + /** * @hidden */ @@ -1593,7 +1766,7 @@ export class Encoding { * @deprecation * @hidden */ - decodePath(encoded: string, precision?: number): LatLng { + decodePath(encoded: string, precision?: number): Array { console.error('GoogleMaps', '[deprecated] This method is static. Please use Encoding.decodePath()'); return Encoding.decodePath(encoded, precision); } @@ -1611,16 +1784,20 @@ export class Encoding { * Decodes an encoded path string into a sequence of LatLngs. * @param encoded {string} an encoded path string * @param precision? {number} default: 5 - * @return {LatLng} + * @return {ILatLng[]} */ - static decodePath(encoded: string, precision?: number): LatLng { return; } + static decodePath(encoded: string, precision?: number): Array { + return GoogleMaps.getPlugin().geometry.encoding.decodePath(encoded, precision); + } /** * Encodes a sequence of LatLngs into an encoded path string. * @param path {Array | BaseArrayClass} a sequence of LatLngs * @return {string} */ - static encodePath(path: Array | BaseArrayClass): string { return; } + static encodePath(path: Array | BaseArrayClass): string { + return GoogleMaps.getPlugin().geometry.encoding.encodePath(path); + } } /** @@ -1904,7 +2081,7 @@ export class GoogleMap extends BaseClass { /** * Changes the map div - * @param domNode + * @param domNode {HTMLElement | string} [options] If you want to display the map in an html element, you need to specify an element or id. If omit this argument, the map is detached from webview. */ @InstanceCheck() setDiv(domNode?: HTMLElement | string): void { @@ -2112,12 +2289,19 @@ export class GoogleMap extends BaseClass { fromPointToLatLng(point: any): Promise { return; } /** - * Set true if you want to show the MyLocation button + * Set true if you want to show the MyLocation control (blue dot) * @param enabled {boolean} */ @CordovaInstance({ sync: true }) setMyLocationEnabled(enabled: boolean): void {} + /** + * Set true if you want to show the MyLocation button + * @param enabled {boolean} + */ + @CordovaInstance({ sync: true }) + setMyLocationButtonEnabled(enabled: boolean): void {} + /** * Get the currently focused building * @return {Promise} @@ -2179,6 +2363,7 @@ export class GoogleMap extends BaseClass { /** * Adds a marker + * @param options {MarkerOptions} options * @return {Promise} */ @InstanceCheck() @@ -2203,6 +2388,11 @@ export class GoogleMap extends BaseClass { }); } + /** + * Adds a marker cluster + * @param options {MarkerClusterOptions} options + * @return {Promise} + */ @InstanceCheck() addMarkerCluster(options: MarkerClusterOptions): Promise { return new Promise((resolve, reject) => { @@ -2228,6 +2418,7 @@ export class GoogleMap extends BaseClass { /** * Adds a circle + * @param options {CircleOptions} options * @return {Promise} */ @InstanceCheck() @@ -2254,6 +2445,7 @@ export class GoogleMap extends BaseClass { /** * Adds a polygon + * @param options {PolygonOptions} options * @return {Promise} */ @InstanceCheck() @@ -2279,7 +2471,8 @@ export class GoogleMap extends BaseClass { } /** - * + * Adds a polyline + * @param options {PolylineOptions} options * @return {Promise} */ @InstanceCheck() @@ -2305,6 +2498,8 @@ export class GoogleMap extends BaseClass { } /** + * Adds a tile overlay + * @param options {TileOverlayOptions} options * @return {Promise} */ @InstanceCheck() @@ -2330,6 +2525,8 @@ export class GoogleMap extends BaseClass { } /** + * Adds a ground overlay + * @param options {GroundOverlayOptions} options * @return {Promise} */ @InstanceCheck() @@ -2355,33 +2552,39 @@ export class GoogleMap extends BaseClass { } /** - * Refreshes layout. - * You can execute it, but you don't need to do that. The plugin does this automatically. + * Adds a kml overlay + * @param options {KmlOverlayOptions} options + * @return {Promise} */ - @CordovaInstance({ sync: true }) - refreshLayout(): void {} + @InstanceCheck() + addKmlOverlay(options: KmlOverlayOptions): Promise { + return new Promise((resolve, reject) => { + this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => { + if (kmlOverlay) { + let overlayId: string = kmlOverlay.getId(); + const overlay = new KmlOverlay(this, kmlOverlay); + this.get('_overlays')[overlayId] = overlay; + kmlOverlay.one(overlayId + '_remove', () => { + if (this.get('_overlays')) { + this.get('_overlays')[overlayId] = null; + overlay.destroy(); + } + }); + resolve(overlay); + } else { + reject(); + } + }); + }); + } /** - * @return {Promise} + * Returns the base64 encoded screen capture of the map. + * @param options {ToDataUrlOptions} [options] options + * @return {Promise} */ @CordovaInstance() - toDataURL(): Promise { return; } - - // /** - // * @return {Promise} - // */ - // @InstanceCheck() - // addKmlOverlay(options: KmlOverlayOptions): Promise { - // return new Promise((resolve, reject) => { - // this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => { - // if (kmlOverlay) { - // resolve(new KmlOverlay(kmlOverlay)); - // } else { - // reject(); - // } - // }); - // }); - // } + toDataURL(params?: ToDataUrlOptions): Promise { return; } } @@ -2409,7 +2612,7 @@ export class GroundOverlay extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Change the bounds of the GroundOverlay @@ -2575,7 +2778,7 @@ export class Marker extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Set the marker position. @@ -2790,12 +2993,24 @@ export class MarkerCluster extends BaseClass { @CordovaInstance({ sync: true }) getId(): string { return; } + /** + * Add one marker location + * @param marker {MarkerOptions} one location + * @param skipRedraw? {boolean} marker cluster does not redraw the marker cluster if true. + */ @CordovaInstance({ sync: true }) - addMarker(marker: MarkerOptions): void {} + addMarker(marker: MarkerOptions, skipRedraw?: boolean): void {} + /** + * Add marker locations + * @param markers {MarkerOptions[]} multiple locations + */ @CordovaInstance({ sync: true }) addMarkers(markers: MarkerOptions[]): void {} + /** + * Remove the marker cluster + */ @InstanceCheck() remove(): void { this._objectInstance.set('_overlays', undefined); @@ -2808,7 +3023,7 @@ export class MarkerCluster extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } } @@ -2836,7 +3051,7 @@ export class Polygon extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Change the polygon points. @@ -3008,7 +3223,7 @@ export class Polyline extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Change the polyline points. @@ -3145,7 +3360,7 @@ export class TileOverlay extends BaseClass { * Return the map instance. * @return {GoogleMap} */ - getMap(): any { return this._map; } + getMap(): GoogleMap { return this._map; } /** * Set whether the tiles should fade in. @@ -3220,102 +3435,82 @@ export class TileOverlay extends BaseClass { } } -// /** -// * @hidden -// */ -// export interface KmlOverlayOptions { -// url?: string; -// preserveViewport?: boolean; -// animation?: boolean; -// } -// /** -// * @hidden -// */ -// export class KmlOverlay { -// -// constructor(private _objectInstance: any) { } -// -// /** -// * Adds an event listener. -// * -// * @return {Observable} -// */ -// addEventListener(eventName: string): Observable { -// return Observable.fromEvent(this._objectInstance, eventName); -// } -// -// /** -// * Adds an event listener that works once. -// * -// * @return {Promise} -// */ -// addListenerOnce(eventName: string): Promise { -// if (!this._objectInstance) { -// return Promise.reject({ error: 'plugin_not_installed' }); -// } -// return new Promise( -// resolve => this._objectInstance.addListenerOnce(eventName, resolve) -// ); -// } -// -// /** -// * Gets a value -// * @param key -// */ -// @CordovaInstance({ sync: true }) -// get(key: string): any { return; } -// -// /** -// * Sets a value -// * @param key -// * @param value -// */ -// @CordovaInstance({ sync: true }) -// set(key: string, value: any): void { } -// -// /** -// * Listen to a map event. -// * -// * @return {Observable} -// */ -// on(eventName: string): Observable { -// if (!this._objectInstance) { -// return new Observable((observer) => { -// observer.error({ error: 'plugin_not_installed' }); -// }); -// } -// -// return new Observable( -// (observer) => { -// this._objectInstance.on(eventName, observer.next.bind(observer)); -// return () => this._objectInstance.off(event); -// } -// ); -// } -// -// /** -// * Listen to a map event only once. -// * -// * @return {Promise} -// */ -// one(eventName: string): Promise { -// if (!this._objectInstance) { -// return Promise.reject({ error: 'plugin_not_installed' }); -// } -// return new Promise( -// resolve => this._objectInstance.one(eventName, resolve) -// ); -// } -// -// /** -// * Clears all stored values -// */ -// @CordovaInstance({ sync: true }) -// empty(): void { } -// -// @CordovaInstance({ sync: true }) -// remove(): void { } -// -// @CordovaInstance({ sync: true }) -// getOverlays(): Array { return; } -// } +/** + * @hidden + */ +export class KmlOverlay extends BaseClass { + + private _map: GoogleMap; + + constructor(_map: GoogleMap, _objectInstance: any) { + super(); + this._map = _map; + this._objectInstance = _objectInstance; + + Object.defineProperty(self, 'camera', { + value: this._objectInstance.camera, + writable: false + }); + Object.defineProperty(self, 'kmlData', { + value: this._objectInstance.kmlData, + writable: false + }); + } + + /** + * Returns the viewport to contains all overlays + */ + @CordovaInstance({ sync: true }) + getDefaultViewport(): CameraPosition { return; } + + /** + * Return the ID of instance. + * @return {string} + */ + @CordovaInstance({ sync: true }) + getId(): string { return; } + + /** + * Return the map instance. + * @return {GoogleMap} + */ + getMap(): GoogleMap { return this._map; } + + /** + * Change visibility of the polyline + * @param visible {boolean} + */ + @CordovaInstance({ sync: true }) + setVisible(visible: boolean): void {} + + /** + * Return true if the polyline is visible + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getVisible(): boolean { return; } + + /** + * Change clickablity of the KmlOverlay + * @param clickable {boolean} + */ + @CordovaInstance({ sync: true }) + setClickable(clickable: boolean): void {} + + /** + * Return true if the KmlOverlay is clickable + * @return {boolean} + */ + @CordovaInstance({ sync: true }) + getClickable(): boolean { return; } + + /** + * Remove the KmlOverlay + */ + @InstanceCheck() + remove(): void { + delete this._objectInstance.getMap().get('_overlays')[this.getId()]; + this._objectInstance.remove(); + this.destroy(); + } +}