0

I am using Ionic 3 with @ionic-native/google-maps (https://github.com/ionic-team/ionic-native-google-maps/blob/master/documents/README.md).

I am using markerCluster to populate the map with markers.

At the moment, to update the markers, I am performing a map.clear(), as it can be seen in the code below.

The problem I have is that the markers are "flashing" when the map is clearing and the new one are created. By "flashing", I am trying to say that you can see how it disappears and appears again.

Is there a way to remove a marker from markerCluster, instead of clearing the map?

I am using this code to show on map some locations with some updates.

E.g.:

  • the pin is green if available
  • the pin is blue if in used
  • remove pin if offline

So, I am calling the WS to get the status every few seconds and update the pins icons based on the status.

I have tried markerCluster.remove(), instead of map.clear(), but the pin is not removed from the map.

this.map.clear();
markerCluster = this.map.addMarkerClusterSync({
    markers: this.markers,
    icons: [
           {
             min: 2,
             max: 9,
             url: this.assetsPath + "images/pin_cluster.png",
             label: {
                    color: "black",
                    fontSize: 15,
                  },
             size: { width: 40, height: 40 }
            }],
              boundsDraw: false
            });
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Acnud
  • 11
  • 3
  • Instead of clearing the map, set that specific marker's map to null. See related https://stackoverflow.com/questions/4249870/google-maps-api-v3-how-to-remove-cluster-icons – evan Sep 08 '19 at 10:52
  • You could also use `markerCluster.removeMarker`, see https://stackoverflow.com/questions/25302466/how-to-remove-the-marker-from-the-cluster-in-google-map – evan Sep 08 '19 at 10:59

0 Answers0