Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

How to clear marker? #145

Open
firdausalif opened this issue Aug 21, 2018 · 3 comments
Open

How to clear marker? #145

firdausalif opened this issue Aug 21, 2018 · 3 comments

Comments

@firdausalif
Copy link

Hello,
i got no idea to clear marker with setMap(null)
can somebody explain to me pls?

my code:
`var markerList = [];
function initMap(){

var center = {lat: -5.302420, lng: 116.140801};
var infowindow;

$('#map, #mapInstansi')
.gmap3({
    center:[center.lat, center.lng],
    zoom:5
})
.infowindow({
    content: ''
 })
.then(function (iw) {
    infowindow = iw;
})
.cluster({
    size: 200,
    markers: markerList,
    cb: function (markers) {
      if (markers.length > 1) { // 1 marker stay unchanged (because cb returns nothing)
        if (markers.length < 20) {
            return {
                content: "<div class='cluster cluster-1'>" + markers.length + "</div>",
                x: -26,
                y: -26
                };
            }
        if (markers.length < 50) {
            return {
                content: "<div class='cluster cluster-2'>" + markers.length + "</div>",
                x: -26,
                y: -26
            };
        }
        return {
            content: "<div class='cluster cluster-3'>" + markers.length + "</div>",
            x: -33,
            y: -33
        };
      }
    }
})
.on('click', function (marker, clusterOverlay, cluster, event) {
    if (marker) {
      infowindow.setContent(marker.info);
      infowindow.open(marker.getMap(), marker);
    }
});

}`

@uresu
Copy link

uresu commented Jan 29, 2020

You're not the only one with this problem, there are a number of tickets with the same issue as well as numerous stackoverflow posts. I'm guessing either @jbdemonte doesn't actually know how to easily do this or is unwilling to accurately document it.

@adam-jones-net
Copy link

@uresu you didn't get a fix did you ?

@uresu
Copy link

uresu commented Feb 24, 2020

Nope. He doesn't know how to fix it.

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

No branches or pull requests

3 participants