javascript - Get location of the group marker with Leafletjs + markercluster plugin -
i using leafletjs draw rental houses on map (using openstreetmap too) , i'm using leaflet.markercluster group these markers on marker cluster, until user zooms in map.
on grouped icons show number of rental houses grouped in cluster, , want draw circle when put mouse on grouped icon. circle size depends on number of markers grouped, , need center of circle in same location of marker cluster.
my problem can't location of cluster marker, tried catch onmouseover event , location it's location of first marker of group.
in ideal case, need cluster marker icon in middle of grouped markers , radius of circle cover of grouped markers position problem is, how grouped marker position.
this markercluster code.
var markers = new l.markerclustergroup(); (var = 0; < addresspoints.length; i++) { var = addresspoints[i]; var title = a[2]; var marker = l.marker(new l.latlng(a[0], a[1]), { title: title }); var htmlpopup = '<div><span class="marker-count">'+title+'</span></div>'; marker.bindpopup(htmlpopup); markers.addlayer(marker); } map.addlayer(markers); //create circlemarker on hover var circlemarker = l.circle([-9999,-9999], "-1").addto(map); markers.on('clustermouseover', function (a) { var circleradius = a.layer.getallchildmarkers().length *10000 / math.pow(map.getzoom(), 3); circlemarker.setlatlng([a.layer._clatlng.lat,a.layer._clatlng.lng]); circlemarker.setradius(circleradius); }); addresspoints contains latitude , longitude points markers
this should simple, try:
markers.on('clustermouseover', function (e) { console.log(e.latlng); }
Comments
Post a Comment