mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 914 forks source link

Bug index.js = @ionic-native/google-maps/index.js #2731

Closed DavidPerez2017 closed 4 years ago

DavidPerez2017 commented 4 years ago

public support

If you have a question about this plugin, please ask here. However this is not a good place for Q&A, please ask only things related with this plugin (such as how to use).

If you want to report your problem, please share your project files on Github in advance. Without your project files, I can only guess your issue (except your issue is really easy case). Sharing your project files in advance is the fastest way to resolve your issue.

I'm submitting a ... (check one with "x")

OS: (check one with "x")

cordova information: (run $> cordova plugin list)

insert the output from the command here

cordova-plugin-android-permissions 1.0.2 "Permissions" cordova-plugin-device 2.0.2 "Device" cordova-plugin-facebook4 6.2.0 "Facebook Connect" cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps" cordova-plugin-googleplus 8.2.1 "Google SignIn" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview" cordova-plugin-request-location-accuracy 2.3.0 "Request Location Accuracy" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-telerik-imagepicker 2.3.3 "ImagePicker" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.6.3 "SocialSharing" cordova-sqlite-storage 4.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-deeplinks 1.0.20 "Ionic Deeplink Plugin"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

@ionic-native/core : "^5.19.0"
@ionic-native/google-maps :  "^5.5.0"

Current behavior:

When switching between a map that uses addMarkerCluster and another that uses addMarkerSync at some point the bug is triggered and blocks the map:

r2

r3

r4

Expected behavior:

Browse the map and see the markers.

Related code, data or error log (please format your code or data):

this.map.one(GoogleMapsEvent.MAP_READY) .then(() => { this.map.addMarkerCluster(options).then((markerCluster: MarkerCluster) => {

    markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => {
            const marker: Marker = params[1];
            const titleNew = marker.get('name');
            const frame: HTMLElement = document.createElement('div');
            if (rateNew === 0) {
              frame.innerHTML = `<h4 style="text-align: center;
                          width: 90%;
                          overflow:hidden;
                          white-space: nowrap;
                          text-overflow: ellipsis;
                          word-wrap: break-word;">` + titleNew + `</h4>`;
            this.htmlInfoWindow.setContent(frame, { width: '140px', height: '130px' });
            this.htmlInfoWindow.open(marker);
          });

        }, (error) => {
          console.log(error);
        });
    }
    }).catch(error => {
    console.log(error);
    this.globalService.loading = false;

});



I solved it by adding the if condition and I would like it to be corrected in the repository:

 **if (_objectInstance.getMap().get('_overlays')) {**
            _objectInstance.getMap().get('_overlays')[markerId_1] = null;
             delete _objectInstance.getMap().get('_overlays')[markerId_1];
 **}**
wf9a5m75 commented 4 years ago

Could you create a simple project, and share it on github?

DavidPerez2017 commented 4 years ago

No, in a simple project I have not been able to replicate it and I cannot share this project due to company policies. That is why I propose the solution made in my project that consists of adding the validation in the line of 339:

if (objectInstance.getMap (). get (' overlays')) {

Note: I will keep trying to replicate the error.