Skip to content

Commit

Permalink
fix(google-maps): various fixed introduced in previous release (#2024)
Browse files Browse the repository at this point in the history
* 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
#1815 (comment)

* 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

mapsplugin/cordova-plugin-googlemaps#1712

* Update index.ts

* fix: need to convert instance type from the JS class to the wrapper class

mapsplugin/cordova-plugin-googlemaps#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 #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.
  • Loading branch information
wf9a5m75 authored and ihadeed committed Oct 6, 2017
1 parent 536a906 commit 6ca5bea
Showing 1 changed file with 117 additions and 14 deletions.
131 changes: 117 additions & 14 deletions src/@ionic-native/plugins/google-maps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = {
pluginRef: 'plugin.google.maps',
plugin: 'cordova-plugin-googlemaps',
repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps',
install: 'ionic cordova plugin add https://github.com/mapsplugin/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"',
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']
})
Expand Down Expand Up @@ -656,6 +656,21 @@ export class BaseClass {
if (args[args.length - 1] instanceof GoogleMaps.getPlugin().BaseClass) {
if (args[args.length - 1].type === 'Map') {
args[args.length - 1] = this;
} else if (this instanceof MarkerCluster) {
let overlay: Marker = this.get(args[args.length - 1].getId());
if (!overlay) {
let markerJS: any = args[args.length - 1];
let markerCluster: MarkerCluster = <MarkerCluster>this;
overlay = new Marker(markerCluster.getMap(), markerJS);
this.get('_overlays').push(markerJS.getId());
this.set(markerJS.getId(), overlay);
markerJS.one(markerJS.getId() + '_remove', () => {
let idx = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerJS.getId(), undefined);
});
}
args[args.length - 1] = overlay;
} else {
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
}
Expand All @@ -677,6 +692,21 @@ export class BaseClass {
if (args[args.length - 1] instanceof GoogleMaps.getPlugin().BaseClass) {
if (args[args.length - 1].type === 'Map') {
args[args.length - 1] = this;
} else if (this instanceof MarkerCluster) {
let overlay: Marker = this.get(args[args.length - 1].getId());
if (!overlay) {
let markerJS: any = args[args.length - 1];
let markerCluster: MarkerCluster = <MarkerCluster>this;
overlay = new Marker(markerCluster.getMap(), markerJS);
this.get('_overlays').push(markerJS.getId());
this.set(markerJS.getId(), overlay);
markerJS.one(markerJS.getId() + '_remove', () => {
let idx = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerJS.getId(), undefined);
});
}
args[args.length - 1] = overlay;
} else {
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
}
Expand Down Expand Up @@ -723,6 +753,21 @@ export class BaseClass {
if (args[args.length - 1] instanceof GoogleMaps.getPlugin().BaseClass) {
if (args[args.length - 1].type === 'Map') {
args[args.length - 1] = this;
} else if (this instanceof MarkerCluster) {
let overlay: Marker = this.get(args[args.length - 1].getId());
if (!overlay) {
let markerJS: any = args[args.length - 1];
let markerCluster: MarkerCluster = <MarkerCluster>this;
overlay = new Marker(markerCluster.getMap(), markerJS);
this.get('_overlays').push(markerJS.getId());
this.set(markerJS.getId(), overlay);
markerJS.one(markerJS.getId() + '_remove', () => {
let idx = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerJS.getId(), undefined);
});
}
args[args.length - 1] = overlay;
} else {
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
}
Expand All @@ -744,6 +789,21 @@ export class BaseClass {
if (args[args.length - 1] instanceof GoogleMaps.getPlugin().BaseClass) {
if (args[args.length - 1].type === 'Map') {
args[args.length - 1] = this;
} else if (this instanceof MarkerCluster) {
let overlay: Marker = this.get(args[args.length - 1].getId());
if (!overlay) {
let markerJS: any = args[args.length - 1];
let markerCluster: MarkerCluster = <MarkerCluster>this;
overlay = new Marker(markerCluster.getMap(), markerJS);
this.get('_overlays').push(markerJS.getId());
this.set(markerJS.getId(), overlay);
markerJS.one(markerJS.getId() + '_remove', () => {
let idx = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerJS.getId(), undefined);
});
}
args[args.length - 1] = overlay;
} else {
args[args.length - 1] = this._objectInstance.getMap().get(args[args.length - 1].getId());
}
Expand Down Expand Up @@ -1567,9 +1627,15 @@ export class GoogleMap extends BaseClass {
return new Promise<Marker>((resolve, reject) => {
this._objectInstance.addMarker(options, (marker: any) => {
if (marker) {
let markerId: string = marker.getId();
const overlay: Marker = new Marker(this, marker);
this.get('_overlays').push(marker.getId());
this.set(marker.getId(), overlay);
this.get('_overlays').push(markerId);
this.set(markerId, overlay);
marker.one(markerId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerId, undefined);
});
resolve(overlay);
} else {
reject();
Expand All @@ -1586,6 +1652,12 @@ export class GoogleMap extends BaseClass {
const overlay = new MarkerCluster(this, markerCluster);
this.get('_overlays').push(markerCluster.getId());
this.set(markerCluster.getId(), overlay);
markerCluster.one('remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(markerCluster.getId(), undefined);
});
markerCluster.set('_overlays', new BaseArrayClass());
resolve(overlay);
} else {
reject();
Expand All @@ -1603,9 +1675,15 @@ export class GoogleMap extends BaseClass {
return new Promise<Circle>((resolve, reject) => {
this._objectInstance.addCircle(options, (circle: any) => {
if (circle) {
let circleId: string = circle.getId();
const overlay = new Circle(this, circle);
this.get('_overlays').push(circle.getId());
this.set(circle.getId(), overlay);
this.get('_overlays').push(circleId);
this.set(circleId, overlay);
circle.one(circleId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(circleId, undefined);
});
resolve(overlay);
} else {
reject();
Expand All @@ -1623,10 +1701,16 @@ export class GoogleMap extends BaseClass {
return new Promise<Polygon>((resolve, reject) => {
this._objectInstance.addPolygon(options, (polygon: any) => {
if (polygon) {
let polygonId: string = polygon.getId();
const overlay = new Polygon(this, polygon);
this.get('_overlays').push(polygon.getId());
this.set(polygon.getId(), overlay);
resolve(polygon);
this.get('_overlays').push(polygonId);
this.set(polygonId, overlay);
polygon.one(polygonId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(polygonId, undefined);
});
resolve(overlay);
} else {
reject();
}
Expand All @@ -1643,9 +1727,15 @@ export class GoogleMap extends BaseClass {
return new Promise<Polyline>((resolve, reject) => {
this._objectInstance.addPolyline(options, (polyline: any) => {
if (polyline) {
let polylineId: string = polyline.getId();
const overlay = new Polyline(this, polyline);
this.get('_overlays').push(polyline.getId());
this.set(polyline.getId(), overlay);
this.get('_overlays').push(polylineId);
this.set(polylineId, overlay);
polyline.one(polylineId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(polylineId, undefined);
});
resolve(overlay);
} else {
reject();
Expand All @@ -1662,9 +1752,15 @@ export class GoogleMap extends BaseClass {
return new Promise<TileOverlay>((resolve, reject) => {
this._objectInstance.addTileOverlay(options, (tileOverlay: any) => {
if (tileOverlay) {
let tileOverlayId: string = tileOverlay.getId();
const overlay = new TileOverlay(this, tileOverlay);
this.get('_overlays').push(tileOverlay.getId());
this.set(tileOverlay.getId(), overlay);
this.get('_overlays').push(tileOverlayId);
this.set(tileOverlayId, overlay);
tileOverlay.one(tileOverlayId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(tileOverlayId, undefined);
});
resolve(overlay);
} else {
reject();
Expand All @@ -1681,9 +1777,15 @@ export class GoogleMap extends BaseClass {
return new Promise<GroundOverlay>((resolve, reject) => {
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
if (groundOverlay) {
let groundOverlayId: string = groundOverlay.getId();
const overlay = new GroundOverlay(this, groundOverlay);
this.get('_overlays').push(groundOverlay.getId());
this.set(groundOverlay.getId(), overlay);
this.get('_overlays').push(groundOverlayId);
this.set(groundOverlayId, overlay);
groundOverlay.one(groundOverlayId + '_remove', () => {
let idx: number = this.get('_overlays').indexOf(overlay);
this.get('_overlays').removeAt(idx);
this.set(groundOverlayId, undefined);
});
resolve(overlay);
} else {
reject();
Expand Down Expand Up @@ -2141,6 +2243,7 @@ export class MarkerCluster extends BaseClass {

@InstanceCheck()
remove(): void {
this._objectInstance.set('_overlays', undefined);
this._objectInstance.getMap().get('_overlays').set(this.getId(), undefined);
this._objectInstance.remove();
this.destroy();
Expand Down

0 comments on commit 6ca5bea

Please sign in to comment.