Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map.clear() do not fires callback function on Android (but on iOS fires) #1669

Closed
lpikora opened this issue Aug 24, 2017 · 5 comments
Closed

Comments

@lpikora
Copy link

lpikora commented Aug 24, 2017

I'm submitting a ... (check one with "x")
[ ] question
[x] any problem or bug report
[ ] feature request

The plugin version: (check one with "x")
[ ] 1.4.x
[x] 2.0.0-beta3 (commit 57287b3)

If you choose 'problem or bug report', please select OS: (check one with "x")
[x] Android
[ ] iOS

cordova information:

com.googlemaps.ios 2.3.0 "Google Maps SDK for iOS"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
cordova-plugin-googlemaps 2.0.0-beta3-20170820-2025 "cordova-plugin-googlemaps"
cordova-plugin-ios-camera-permissions 1.1.1 "iOS Permissions"
cordova-plugin-ios-non-exempt-encryption 1.0.0 "ITSAppUsesNonExemptEncryption false"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-wkwebview-engine 1.1.4-dev "Cordova WKWebView Engine"
cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Current behavior:
Clear method of Map class do not call callback function on Android.

map.clear(function() {
// not fired
});

Expected behavior:
Clear method of Map class should call callback function on Android.

map.clear(function() {
// fired
});

Steps to reproduce:

alert('map clear callback fn') is not called.

<div class="map" id="map_canvas">
    <span class="smallPanel"><button>Click here</button></span>
</div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div);
map.one(plugin.google.maps.event.MAP_READY, function() {

  var button = div.getElementsByTagName('button')[0];
  button.addEventListener('click', function() {
    // Removes the markers completely.
    map.clear(function() {
      alert('map clear callback fn')
    });
  });

  // Puts random markers on the map.
  createMarkers(map);
});
function createMarkers(map) {
  var latLngBounds = map.getVisibleRegion();
  var sw = latLngBounds.southwest;
  var ne = latLngBounds.northeast;
  var diffY = (ne.lat - sw.lat);
  var diffX = (ne.lng - sw.lng);
  for (var i = 0; i < 100; i++) {
    map.addMarker({
      'position': {
        'lat': sw.lat + diffY * Math.random(),
        'lng': sw.lng  + diffX * Math.random()
      }
    });
  }
}
@wf9a5m75
Copy link
Member

Did you try the latest version?

@lpikora
Copy link
Author

lpikora commented Aug 24, 2017

Yes, i tried run the same JS code with e66cd25 but still fails to call callback function of map.clear(). And as a side effect after calling map.clear() no more markers can be added to the map. Calling method map.addMarker does not add marker to the map and also not fires callback function of this method. iOS works fine.

Last commit that works form me (map.clear() fires callback and markers can be added then is 20c6b30).

I'll do some more testing with simple app - maybe some specific use of maps plugin in my project cause this behavior...

@wf9a5m75
Copy link
Member

I can not confirm your issue.

  clearMap() {
    this.map.clear(function() {
      alert("clear!");
    });
  }

issue_1669

@wf9a5m75
Copy link
Member

I finally figured out the bug. Please reinstall the latest version.

@lpikora
Copy link
Author

lpikora commented Aug 25, 2017

It works now with your latest commit. Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants