* Update index.ts * Update index.ts * Add missing features, and bug fix of methods * update: classname must be in pascal case * remove: duplicated class definition * export encode and spherical static classes * Add comma * Fix Encoding and Spherical * Add convenience methods * Fix decorators for Encoding and Spherical * Update: getMap() methods return the instance of the wrapper plugin * Update: getMap() methods return the instance of the wrapper plugin * Remove `@CordovaInstance` decorators from getMap() * Update: GoogleMapOptions (all fields are not optional). * Follow up: version `2.0.0-beta2-20170719-2226` of cordova-plugin-googlemaps * Fix: tslint error * Fix: tslint error * No more isAvailable() method. * Bug fix: description is incorrect * Bug fix: example code was wrong. * Bug fix: HtmlInfoWindow does not work https://github.com/ionic-team/ionic-native/pull/1815#issuecomment-318909795 * Bug fix: HtmlInfoWindow does not work * Bug fix: HtmlInfoWindow does not work * Bug fix: HtmlInfoWindow does not work * Bug fix: HtmlInfoWindow does not work * It seems the ionViewDidLoad() is enough delayed after platform.ready() * Bug fix: map.setDiv() * Bug fix: HtmlInfoWindow does not work * Bug fix: BaseArrayClass definition is incorrect * Bug fix: BaseArrayClass constructor is wrong * Bug fix: Geocoder class does not work * Bug fix: LatLngBounds constructor is wrong * update: noNotify option is not declared * Bug fix: Geocoder.geocode() returns array of GeocoderResult * Update: clarify acceptable parameters of BaseArrayClass * Add: AnimateCameraOption.padding is missing * Revert: BaseClass.empty() method does not have the noNotify option * Add `destruct` option to the CordovaOption. - This allows BaseClass.on() is able to pass multiple retuned values from the cordova plugin side to the event lister. * A semicolon is mixing * update: event names * Update: BaseClass.addEventListener(), addEventListenerOnce(), on(), and one() * Add: destruct option for otherPromise Change: inside event names (must use the version 2.0.0-beta3-20170808-1950 or higher) * Build for working group * Bug fix: map.getCameraTarget() definition is incorrect * Bug fix: The definition of VisibleRegion interface is incorrect * Fix: LatLng, LatLngBounds, and PolylineOptions classes Update: map.getVisibleRegion() Add: VisibleRegion class * Bug fix: the definition of map.clear() method is incorrect * Fix: map.fromLatLngToPoint() * Ignore the dist directory on the master branch * Remove the dist folder on the master branch * fixes and tweaks * use union types for CameraPosition fixes issue mentioned on slack by @wf9a5m75 * fix types * update AnimateCameraOptions interface * remove AnimateCameraOptions interface * add MarkerCluster class * Bug fix: Can not create an instance of BaseArrayClass * Bug fix: the icons property of MarkerClusterOptions * Bug fix: the zoom option is missing https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1712 * Update index.ts * fix: need to convert instance type from the JS class to the wrapper class https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1706 * remove test file * fix: Error: Illegal use of "@private" tag. * fix: The Environment, Encode, and Spherical are static class * fix: convert JS instance to the ionic instance add: BaseClass.destroy() add: getId() method for all instance classes * Documentation Error https://github.com/ionic-team/ionic-native/issues/1994 * Need to create another way to convert the instance for marker cluster * save * Remove the instance of wrapper class if the JS instance is removed. * Bug fix: HtmlInfoWindow missing .on and .one methods https://github.com/ionic-team/ionic-native/issues/2034 * Bug fix: HtmlInfoWindow constructor cause the error https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1661 * Fix: Error when removing map https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1823 * Add: the cssOptions argument for HtmlInfoWindow.setContent() method * Bug fix: Polyline.getPoints(), Polygon.getPoints() and Polygon.getHoles() Those methods need to create new instance of BaseArrayClass of wrapper plugin. * Add: forEachAsync(), mapAsync(), and filterAsync() methods into BaseArray class * update: use document.querySelector() instead of document.getElementById() if the passed element is string update: map.setDiv() Bug fix: can not create empty GoogleMap (pure JS version is available way) * Fix: wait until the page is fully ready * Fix: missing `clickable` option for PolygonOptions and PolylineOptions
This commit is contained in:
parent
7243ed3960
commit
ce6e412788
@ -375,6 +375,7 @@ export interface PolygonOptions {
|
|||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
addHole?: Array<Array<ILatLng>>;
|
addHole?: Array<Array<ILatLng>>;
|
||||||
|
clickable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PolylineOptions {
|
export interface PolylineOptions {
|
||||||
@ -384,6 +385,7 @@ export interface PolylineOptions {
|
|||||||
color?: string;
|
color?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
|
clickable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TileOverlayOptions {
|
export interface TileOverlayOptions {
|
||||||
@ -517,7 +519,6 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = {
|
|||||||
* })
|
* })
|
||||||
* export class HomePage {
|
* export class HomePage {
|
||||||
* map: GoogleMap;
|
* map: GoogleMap;
|
||||||
* mapElement: HTMLElement;
|
|
||||||
* constructor(private googleMaps: GoogleMaps) { }
|
* constructor(private googleMaps: GoogleMaps) { }
|
||||||
*
|
*
|
||||||
* ionViewDidLoad() {
|
* ionViewDidLoad() {
|
||||||
@ -525,7 +526,6 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = {
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* loadMap() {
|
* loadMap() {
|
||||||
* this.mapElement = document.getElementById('map');
|
|
||||||
*
|
*
|
||||||
* let mapOptions: GoogleMapOptions = {
|
* let mapOptions: GoogleMapOptions = {
|
||||||
* camera: {
|
* camera: {
|
||||||
@ -538,7 +538,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = {
|
|||||||
* }
|
* }
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* this.map = this.googleMaps.create(this.mapElement, mapOptions);
|
* this.map = this.googleMaps.create('map_canvas', mapOptions);
|
||||||
*
|
*
|
||||||
* // Wait the MAP_READY before using any methods.
|
* // Wait the MAP_READY before using any methods.
|
||||||
* this.map.one(GoogleMapsEvent.MAP_READY)
|
* this.map.one(GoogleMapsEvent.MAP_READY)
|
||||||
@ -623,9 +623,18 @@ export class GoogleMaps extends IonicNativePlugin {
|
|||||||
* @param options {any} Options
|
* @param options {any} Options
|
||||||
* @return {GoogleMap}
|
* @return {GoogleMap}
|
||||||
*/
|
*/
|
||||||
create(element: string | HTMLElement, options?: GoogleMapOptions): GoogleMap {
|
create(element: string | HTMLElement | GoogleMapOptions, options?: GoogleMapOptions): GoogleMap {
|
||||||
let googleMap: GoogleMap = new GoogleMap(element, options);
|
if (element instanceof HTMLElement) {
|
||||||
googleMap.set('_overlays', new BaseArrayClass());
|
if (element.getAttribute('__pluginMapId')) {
|
||||||
|
console.error('GoogleMaps', element.tagName + '[__pluginMapId=\'' + element.getAttribute('__pluginMapId') + '\'] has already map.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (typeof element === 'object') {
|
||||||
|
options = <GoogleMapOptions>element;
|
||||||
|
element = null;
|
||||||
|
}
|
||||||
|
let googleMap: GoogleMap = new GoogleMap(<HTMLElement>element, options);
|
||||||
|
googleMap.set('_overlays', {});
|
||||||
return googleMap;
|
return googleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,19 +669,17 @@ export class BaseClass {
|
|||||||
let overlay: Marker = this.get(args[args.length - 1].getId());
|
let overlay: Marker = this.get(args[args.length - 1].getId());
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
let markerJS: any = args[args.length - 1];
|
let markerJS: any = args[args.length - 1];
|
||||||
|
let markerId: string = markerJS.getId();
|
||||||
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
||||||
overlay = new Marker(markerCluster.getMap(), markerJS);
|
overlay = new Marker(markerCluster.getMap(), markerJS);
|
||||||
this.get('_overlays').push(markerJS.getId());
|
this.get('_overlays')[markerId] = overlay;
|
||||||
this.set(markerJS.getId(), overlay);
|
|
||||||
markerJS.one(markerJS.getId() + '_remove', () => {
|
markerJS.one(markerJS.getId() + '_remove', () => {
|
||||||
let idx = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[markerId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
|
||||||
this.set(markerJS.getId(), undefined);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
args[args.length - 1] = overlay;
|
args[args.length - 1] = overlay;
|
||||||
} else {
|
} else {
|
||||||
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
|
args[args.length - 1] = this._objectInstance.getMap().get('_overlays')[args[args.length - 1].getId()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
observer.next(args);
|
observer.next(args);
|
||||||
@ -696,19 +703,17 @@ export class BaseClass {
|
|||||||
let overlay: Marker = this.get(args[args.length - 1].getId());
|
let overlay: Marker = this.get(args[args.length - 1].getId());
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
let markerJS: any = args[args.length - 1];
|
let markerJS: any = args[args.length - 1];
|
||||||
|
let markerId: string = markerJS.getId();
|
||||||
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
||||||
overlay = new Marker(markerCluster.getMap(), markerJS);
|
overlay = new Marker(markerCluster.getMap(), markerJS);
|
||||||
this.get('_overlays').push(markerJS.getId());
|
this.get('_overlays')[markerId] = overlay;
|
||||||
this.set(markerJS.getId(), overlay);
|
|
||||||
markerJS.one(markerJS.getId() + '_remove', () => {
|
markerJS.one(markerJS.getId() + '_remove', () => {
|
||||||
let idx = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[markerId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
|
||||||
this.set(markerJS.getId(), undefined);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
args[args.length - 1] = overlay;
|
args[args.length - 1] = overlay;
|
||||||
} else {
|
} else {
|
||||||
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
|
args[args.length - 1] = this._objectInstance.getMap().get('_overlays')[args[args.length - 1].getId()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(args);
|
resolve(args);
|
||||||
@ -757,19 +762,17 @@ export class BaseClass {
|
|||||||
let overlay: Marker = this.get(args[args.length - 1].getId());
|
let overlay: Marker = this.get(args[args.length - 1].getId());
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
let markerJS: any = args[args.length - 1];
|
let markerJS: any = args[args.length - 1];
|
||||||
|
let markerId: string = markerJS.getId();
|
||||||
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
||||||
overlay = new Marker(markerCluster.getMap(), markerJS);
|
overlay = new Marker(markerCluster.getMap(), markerJS);
|
||||||
this.get('_overlays').push(markerJS.getId());
|
this.get('_overlays')[markerId] = overlay;
|
||||||
this.set(markerJS.getId(), overlay);
|
|
||||||
markerJS.one(markerJS.getId() + '_remove', () => {
|
markerJS.one(markerJS.getId() + '_remove', () => {
|
||||||
let idx = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[markerId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
|
||||||
this.set(markerJS.getId(), undefined);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
args[args.length - 1] = overlay;
|
args[args.length - 1] = overlay;
|
||||||
} else {
|
} else {
|
||||||
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
|
args[args.length - 1] = this._objectInstance.getMap().get('_overlays')[args[args.length - 1].getId()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
observer.next(args);
|
observer.next(args);
|
||||||
@ -793,19 +796,17 @@ export class BaseClass {
|
|||||||
let overlay: Marker = this.get(args[args.length - 1].getId());
|
let overlay: Marker = this.get(args[args.length - 1].getId());
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
let markerJS: any = args[args.length - 1];
|
let markerJS: any = args[args.length - 1];
|
||||||
|
let markerId: string = markerJS.getId();
|
||||||
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
let markerCluster: MarkerCluster = <MarkerCluster>this;
|
||||||
overlay = new Marker(markerCluster.getMap(), markerJS);
|
overlay = new Marker(markerCluster.getMap(), markerJS);
|
||||||
this.get('_overlays').push(markerJS.getId());
|
this.get('_overlays')[markerId] = overlay;
|
||||||
this.set(markerJS.getId(), overlay);
|
|
||||||
markerJS.one(markerJS.getId() + '_remove', () => {
|
markerJS.one(markerJS.getId() + '_remove', () => {
|
||||||
let idx = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[markerId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
|
||||||
this.set(markerJS.getId(), undefined);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
args[args.length - 1] = overlay;
|
args[args.length - 1] = overlay;
|
||||||
} else {
|
} else {
|
||||||
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
|
args[args.length - 1] = this._objectInstance.getMap().get('_overlays')[args[args.length - 1].getId()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(args);
|
resolve(args);
|
||||||
@ -833,7 +834,7 @@ export class BaseClass {
|
|||||||
destroy(): void {
|
destroy(): void {
|
||||||
let map: GoogleMap = this._objectInstance.getMap();
|
let map: GoogleMap = this._objectInstance.getMap();
|
||||||
if (map) {
|
if (map) {
|
||||||
map.get('_overlays').set(this._objectInstance.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this._objectInstance.getId()];
|
||||||
}
|
}
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
}
|
}
|
||||||
@ -873,26 +874,65 @@ export class BaseArrayClass<T> extends BaseClass {
|
|||||||
* @param callback? {Function}
|
* @param callback? {Function}
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaInstance({ sync: true })
|
||||||
forEach(fn: ((element: T, index?: number) => void) | ((element: T, callback: () => void) => void), callback?: () => void): void {}
|
forEach(fn: (element: T, index?: number) => void): void {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over each element, calling the provided callback.
|
* Iterate over each element, calling the provided callback.
|
||||||
|
* @param fn {Function}
|
||||||
|
* @return {Promise<any>}
|
||||||
|
*/
|
||||||
|
@CordovaCheck()
|
||||||
|
forEachAsync(fn: ((element: T, callback: () => void) => void)): Promise<void> {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
this._objectInstance.forEach(fn, resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over each element, then return a new value.
|
||||||
* Then you can get the results of each callback.
|
* Then you can get the results of each callback.
|
||||||
* @param fn {Function}
|
* @param fn {Function}
|
||||||
* @param callback? {Function}
|
* @param callback? {Function}
|
||||||
* @return {Array<Object>} returns a new array with the results
|
* @return {Array<Object>} returns a new array with the results
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaInstance({ sync: true })
|
||||||
map(fn: Function, callback?: ((element: T, index: number) => T) | ((element: T, callback: (newElement: T) => void) => void)): T[] { return; }
|
map(fn: (element: T, index: number) => any): any[] { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over each element, calling the provided callback.
|
||||||
|
* Then you can get the results of each callback.
|
||||||
|
* @param fn {Function}
|
||||||
|
* @param callback? {Function}
|
||||||
|
* @return {Promise<any>} returns a new array with the results
|
||||||
|
*/
|
||||||
|
@CordovaCheck()
|
||||||
|
mapAsync(fn: ((element: T, callback: (newElement: any) => void) => void)): Promise<any[]> {
|
||||||
|
return new Promise<any[]>((resolve) => {
|
||||||
|
this._objectInstance.map(fn, resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The filter() method creates a new array with all elements that pass the test implemented by the provided function.
|
* The filter() method creates a new array with all elements that pass the test implemented by the provided function.
|
||||||
* @param fn {Function}
|
* @param fn {Function}
|
||||||
* @param callback? {Function}
|
* @param callback? {Function}
|
||||||
* @return {Array<Object>} returns a new array with the results
|
* @return {Array<Object>} returns a new filtered array
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaInstance({ sync: true })
|
||||||
filter(fn: Function, callback?: ((element: T, index: number) => T) | ((element: T, callback: (newElement: T) => void) => void)): T[] { return; }
|
filter(fn: (element: T, index: number) => boolean): T[] { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}
|
||||||
|
* @return {Promise<any>} returns a new filtered array
|
||||||
|
*/
|
||||||
|
@CordovaCheck()
|
||||||
|
filterAsync(fn: (element: T, callback: (result: boolean) => void) => void): Promise<T[]> {
|
||||||
|
return new Promise<any[]>((resolve) => {
|
||||||
|
this._objectInstance.filter(fn, resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the underlying Array.
|
* Returns a reference to the underlying Array.
|
||||||
@ -1349,10 +1389,69 @@ export class GoogleMap extends BaseClass {
|
|||||||
constructor(element: string | HTMLElement, options?: GoogleMapOptions) {
|
constructor(element: string | HTMLElement, options?: GoogleMapOptions) {
|
||||||
super();
|
super();
|
||||||
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
|
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
|
||||||
if (typeof element === 'string') {
|
if (element instanceof HTMLElement) {
|
||||||
element = document.getElementById(<string>element);
|
|
||||||
}
|
|
||||||
this._objectInstance = GoogleMaps.getPlugin().Map.getMap(element, options);
|
this._objectInstance = GoogleMaps.getPlugin().Map.getMap(element, options);
|
||||||
|
} else if (typeof element === 'string') {
|
||||||
|
let dummyObj: any = new (GoogleMaps.getPlugin().BaseClass)();
|
||||||
|
this._objectInstance = dummyObj;
|
||||||
|
let onListeners: any[] = [];
|
||||||
|
let oneListeners: any[] = [];
|
||||||
|
let _origAddEventListener: any = this._objectInstance.addEventListener;
|
||||||
|
let _origAddEventListenerOnce: any = this._objectInstance.addEventListenerOnce;
|
||||||
|
this._objectInstance.addEventListener = (eventName: string, fn: () => void) => {
|
||||||
|
if (eventName === GoogleMapsEvent.MAP_READY) {
|
||||||
|
_origAddEventListener.call(dummyObj, eventName, fn);
|
||||||
|
} else {
|
||||||
|
onListeners.push([dummyObj, fn]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this._objectInstance.on = this._objectInstance.addEventListener;
|
||||||
|
|
||||||
|
this._objectInstance.addEventListenerOnce = (eventName: string, fn: () => void) => {
|
||||||
|
if (eventName === GoogleMapsEvent.MAP_READY) {
|
||||||
|
_origAddEventListenerOnce.call(dummyObj, eventName, fn);
|
||||||
|
} else {
|
||||||
|
oneListeners.push([dummyObj, fn]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this._objectInstance.one = this._objectInstance.addEventListenerOnce;
|
||||||
|
(new Promise<any>((resolve, reject) => {
|
||||||
|
let count: number = 0;
|
||||||
|
let timer: any = setInterval(() => {
|
||||||
|
let target = document.querySelector('.show-page #' + element);
|
||||||
|
if (target) {
|
||||||
|
clearInterval(timer);
|
||||||
|
resolve(target);
|
||||||
|
} else {
|
||||||
|
if (count++ < 20) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearInterval(timer);
|
||||||
|
this._objectInstance.remove();
|
||||||
|
console.error('Can not find the element [#' + element + ']');
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}))
|
||||||
|
.then((target: any) => {
|
||||||
|
this._objectInstance = GoogleMaps.getPlugin().Map.getMap(target, options);
|
||||||
|
this._objectInstance.one(GoogleMapsEvent.MAP_READY, () => {
|
||||||
|
this.set('_overlays', {});
|
||||||
|
onListeners.forEach((args) => {
|
||||||
|
this.on.apply(this, args);
|
||||||
|
});
|
||||||
|
oneListeners.forEach((args) => {
|
||||||
|
this.one.apply(this, args);
|
||||||
|
});
|
||||||
|
dummyObj.trigger(GoogleMapsEvent.MAP_READY);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this._objectInstance = null;
|
||||||
|
});
|
||||||
|
} else if (element === null && options) {
|
||||||
|
this._objectInstance = GoogleMaps.getPlugin().Map.getMap(null, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1360,8 +1459,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
* Changes the map div
|
* Changes the map div
|
||||||
* @param domNode
|
* @param domNode
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@InstanceCheck()
|
||||||
setDiv(domNode?: HTMLElement): void { }
|
setDiv(domNode?: HTMLElement | string): void {
|
||||||
|
if (typeof domNode === 'string') {
|
||||||
|
this._objectInstance.setDiv(document.querySelector('.show-page #' + domNode));
|
||||||
|
} else {
|
||||||
|
this._objectInstance.setDiv(domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the map HTML element
|
* Returns the map HTML element
|
||||||
@ -1517,9 +1622,12 @@ export class GoogleMap extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
remove(): Promise<any> {
|
remove(): Promise<any> {
|
||||||
this.get('_overlays').forEach((overlayId: string) => this.set(overlayId, null));
|
if (this.get('_overlays')) {
|
||||||
this.get('_overlays').empty();
|
Object.keys(this.get('_overlays')).forEach((overlayId: string) => {
|
||||||
this.set('_overlays', undefined);
|
this.get('_overlays')[overlayId] = null;
|
||||||
|
delete this.get('_overlays')[overlayId];
|
||||||
|
});
|
||||||
|
}
|
||||||
return new Promise<any>((resolve) => {
|
return new Promise<any>((resolve) => {
|
||||||
this._objectInstance.remove(() => resolve());
|
this._objectInstance.remove(() => resolve());
|
||||||
});
|
});
|
||||||
@ -1531,8 +1639,12 @@ export class GoogleMap extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@InstanceCheck()
|
@InstanceCheck()
|
||||||
clear(): Promise<any> {
|
clear(): Promise<any> {
|
||||||
this.get('_overlays').forEach((overlayId: string) => this.set(overlayId, null));
|
if (this.get('_overlays')) {
|
||||||
this.get('_overlays').empty();
|
Object.keys(this.get('_overlays')).forEach((overlayId: string) => {
|
||||||
|
this.get('_overlays')[overlayId] = null;
|
||||||
|
delete this.get('_overlays')[overlayId];
|
||||||
|
});
|
||||||
|
}
|
||||||
return new Promise<any>((resolve) => {
|
return new Promise<any>((resolve) => {
|
||||||
this._objectInstance.clear(() => resolve());
|
this._objectInstance.clear(() => resolve());
|
||||||
});
|
});
|
||||||
@ -1627,14 +1739,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<Marker>((resolve, reject) => {
|
return new Promise<Marker>((resolve, reject) => {
|
||||||
this._objectInstance.addMarker(options, (marker: any) => {
|
this._objectInstance.addMarker(options, (marker: any) => {
|
||||||
if (marker) {
|
if (marker) {
|
||||||
let markerId: string = marker.getId();
|
let overlayId: string = marker.getId();
|
||||||
const overlay: Marker = new Marker(this, marker);
|
const overlay: Marker = new Marker(this, marker);
|
||||||
this.get('_overlays').push(markerId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(markerId, overlay);
|
marker.one(overlayId + '_remove', () => {
|
||||||
marker.one(markerId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(markerId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1649,13 +1761,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<MarkerCluster>((resolve, reject) => {
|
return new Promise<MarkerCluster>((resolve, reject) => {
|
||||||
this._objectInstance.addMarkerCluster(options, (markerCluster: any) => {
|
this._objectInstance.addMarkerCluster(options, (markerCluster: any) => {
|
||||||
if (markerCluster) {
|
if (markerCluster) {
|
||||||
|
let overlayId = markerCluster.getId();
|
||||||
const overlay = new MarkerCluster(this, markerCluster);
|
const overlay = new MarkerCluster(this, markerCluster);
|
||||||
this.get('_overlays').push(markerCluster.getId());
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(markerCluster.getId(), overlay);
|
|
||||||
markerCluster.one('remove', () => {
|
markerCluster.one('remove', () => {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
if (this.get('_overlays')) {
|
||||||
this.get('_overlays').removeAt(idx);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.set(markerCluster.getId(), undefined);
|
overlay.destroy();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
markerCluster.set('_overlays', new BaseArrayClass());
|
markerCluster.set('_overlays', new BaseArrayClass());
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
@ -1675,14 +1788,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<Circle>((resolve, reject) => {
|
return new Promise<Circle>((resolve, reject) => {
|
||||||
this._objectInstance.addCircle(options, (circle: any) => {
|
this._objectInstance.addCircle(options, (circle: any) => {
|
||||||
if (circle) {
|
if (circle) {
|
||||||
let circleId: string = circle.getId();
|
let overlayId: string = circle.getId();
|
||||||
const overlay = new Circle(this, circle);
|
const overlay = new Circle(this, circle);
|
||||||
this.get('_overlays').push(circleId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(circleId, overlay);
|
circle.one(overlayId + '_remove', () => {
|
||||||
circle.one(circleId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(circleId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1701,14 +1814,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<Polygon>((resolve, reject) => {
|
return new Promise<Polygon>((resolve, reject) => {
|
||||||
this._objectInstance.addPolygon(options, (polygon: any) => {
|
this._objectInstance.addPolygon(options, (polygon: any) => {
|
||||||
if (polygon) {
|
if (polygon) {
|
||||||
let polygonId: string = polygon.getId();
|
let overlayId: string = polygon.getId();
|
||||||
const overlay = new Polygon(this, polygon);
|
const overlay = new Polygon(this, polygon);
|
||||||
this.get('_overlays').push(polygonId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(polygonId, overlay);
|
polygon.one(overlayId + '_remove', () => {
|
||||||
polygon.one(polygonId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(polygonId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1727,14 +1840,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<Polyline>((resolve, reject) => {
|
return new Promise<Polyline>((resolve, reject) => {
|
||||||
this._objectInstance.addPolyline(options, (polyline: any) => {
|
this._objectInstance.addPolyline(options, (polyline: any) => {
|
||||||
if (polyline) {
|
if (polyline) {
|
||||||
let polylineId: string = polyline.getId();
|
let overlayId: string = polyline.getId();
|
||||||
const overlay = new Polyline(this, polyline);
|
const overlay = new Polyline(this, polyline);
|
||||||
this.get('_overlays').push(polylineId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(polylineId, overlay);
|
polyline.one(overlayId + '_remove', () => {
|
||||||
polyline.one(polylineId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(polylineId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1752,14 +1865,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<TileOverlay>((resolve, reject) => {
|
return new Promise<TileOverlay>((resolve, reject) => {
|
||||||
this._objectInstance.addTileOverlay(options, (tileOverlay: any) => {
|
this._objectInstance.addTileOverlay(options, (tileOverlay: any) => {
|
||||||
if (tileOverlay) {
|
if (tileOverlay) {
|
||||||
let tileOverlayId: string = tileOverlay.getId();
|
let overlayId: string = tileOverlay.getId();
|
||||||
const overlay = new TileOverlay(this, tileOverlay);
|
const overlay = new TileOverlay(this, tileOverlay);
|
||||||
this.get('_overlays').push(tileOverlayId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(tileOverlayId, overlay);
|
tileOverlay.one(overlayId + '_remove', () => {
|
||||||
tileOverlay.one(tileOverlayId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(tileOverlayId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1777,14 +1890,14 @@ export class GoogleMap extends BaseClass {
|
|||||||
return new Promise<GroundOverlay>((resolve, reject) => {
|
return new Promise<GroundOverlay>((resolve, reject) => {
|
||||||
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
|
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
|
||||||
if (groundOverlay) {
|
if (groundOverlay) {
|
||||||
let groundOverlayId: string = groundOverlay.getId();
|
let overlayId: string = groundOverlay.getId();
|
||||||
const overlay = new GroundOverlay(this, groundOverlay);
|
const overlay = new GroundOverlay(this, groundOverlay);
|
||||||
this.get('_overlays').push(groundOverlayId);
|
this.get('_overlays')[overlayId] = overlay;
|
||||||
this.set(groundOverlayId, overlay);
|
groundOverlay.one(overlayId + '_remove', () => {
|
||||||
groundOverlay.one(groundOverlayId + '_remove', () => {
|
if (this.get('_overlays')) {
|
||||||
let idx: number = this.get('_overlays').indexOf(overlay);
|
this.get('_overlays')[overlayId] = null;
|
||||||
this.get('_overlays').removeAt(idx);
|
overlay.destroy();
|
||||||
this.set(groundOverlayId, undefined);
|
}
|
||||||
});
|
});
|
||||||
resolve(overlay);
|
resolve(overlay);
|
||||||
} else {
|
} else {
|
||||||
@ -1822,6 +1935,7 @@ export class GoogleMap extends BaseClass {
|
|||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1938,7 +2052,7 @@ export class GroundOverlay extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@CordovaCheck()
|
@CordovaCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -1953,18 +2067,11 @@ export class GroundOverlay extends BaseClass {
|
|||||||
pluginRef: 'plugin.google.maps.HtmlInfoWindow',
|
pluginRef: 'plugin.google.maps.HtmlInfoWindow',
|
||||||
repo: ''
|
repo: ''
|
||||||
})
|
})
|
||||||
export class HtmlInfoWindow<T> extends IonicNativePlugin {
|
export class HtmlInfoWindow extends BaseClass {
|
||||||
private _objectInstance: any;
|
|
||||||
|
|
||||||
constructor(initialData?: any) {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
if (checkAvailability(HtmlInfoWindow.getPluginRef(), null, HtmlInfoWindow.getPluginName()) === true) {
|
this._objectInstance = new (GoogleMaps.getPlugin().HtmlInfoWindow)();
|
||||||
if (initialData instanceof GoogleMaps.getPlugin().HtmlInfoWindow) {
|
|
||||||
this._objectInstance = initialData;
|
|
||||||
} else {
|
|
||||||
this._objectInstance = new (HtmlInfoWindow.getPlugin())();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1977,9 +2084,10 @@ export class HtmlInfoWindow<T> extends IonicNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* Set your HTML contents.
|
* Set your HTML contents.
|
||||||
* @param content {any} String containing text or HTML element
|
* @param content {any} String containing text or HTML element
|
||||||
|
* @param cssOptions? {any} CSS styles for the container element of HTMLInfoWindow
|
||||||
*/
|
*/
|
||||||
@CordovaInstance()
|
@CordovaInstance()
|
||||||
setContent(content: string | Element): void {}
|
setContent(content: string | Element, cssOptions?: any): void {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the htmlInfoWindow
|
* Open the htmlInfoWindow
|
||||||
@ -2122,7 +2230,7 @@ export class Marker extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@CordovaCheck()
|
@CordovaCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -2244,7 +2352,7 @@ export class MarkerCluster extends BaseClass {
|
|||||||
@InstanceCheck()
|
@InstanceCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.set('_overlays', undefined);
|
this._objectInstance.set('_overlays', undefined);
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -2295,8 +2403,10 @@ export class Polygon extends BaseClass {
|
|||||||
* You can modify the points.
|
* You can modify the points.
|
||||||
* @return {BaseArrayClass<ILatLng>}
|
* @return {BaseArrayClass<ILatLng>}
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaCheck()
|
||||||
getPoints(): BaseArrayClass<ILatLng> { return; }
|
getPoints(): BaseArrayClass<ILatLng> {
|
||||||
|
return new BaseArrayClass<ILatLng>(this._objectInstance.getPoints());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the polygon holes.
|
* Change the polygon holes.
|
||||||
@ -2310,8 +2420,15 @@ export class Polygon extends BaseClass {
|
|||||||
* You can modify the holes.
|
* You can modify the holes.
|
||||||
* @return {BaseArrayClass<ILatLng[]>}
|
* @return {BaseArrayClass<ILatLng[]>}
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaCheck()
|
||||||
getHoles(): BaseArrayClass<ILatLng[]> { return; }
|
getHoles(): BaseArrayClass<ILatLng[]> {
|
||||||
|
let holes: ILatLng[][] = this._objectInstance.getPoints();
|
||||||
|
let results: BaseArrayClass<ILatLng[]> = new BaseArrayClass<ILatLng[]>();
|
||||||
|
holes.forEach((hole: ILatLng[]) => {
|
||||||
|
results.push(hole);
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the filling color (inner color)
|
* Change the filling color (inner color)
|
||||||
@ -2387,7 +2504,7 @@ export class Polygon extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@InstanceCheck()
|
@InstanceCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -2456,9 +2573,12 @@ export class Polyline extends BaseClass {
|
|||||||
/**
|
/**
|
||||||
* Return an instance of the BaseArrayClass
|
* Return an instance of the BaseArrayClass
|
||||||
* You can modify the points.
|
* You can modify the points.
|
||||||
|
* @return {BaseArrayClass<ILatLng>}
|
||||||
*/
|
*/
|
||||||
@CordovaInstance({ sync: true })
|
@CordovaCheck()
|
||||||
getPoints(): BaseArrayClass<ILatLng> { return; }
|
getPoints(): BaseArrayClass<ILatLng> {
|
||||||
|
return new BaseArrayClass<ILatLng>(this._objectInstance.getPoints());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When true, edges of the polyline are interpreted as geodesic and will follow the curvature of the Earth.
|
* When true, edges of the polyline are interpreted as geodesic and will follow the curvature of the Earth.
|
||||||
@ -2548,7 +2668,7 @@ export class Polyline extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@InstanceCheck()
|
@InstanceCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -2647,7 +2767,7 @@ export class TileOverlay extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
@CordovaCheck()
|
@CordovaCheck()
|
||||||
remove(): void {
|
remove(): void {
|
||||||
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
|
delete this._objectInstance.getMap().get('_overlays')[this.getId()];
|
||||||
this._objectInstance.remove();
|
this._objectInstance.remove();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user