Google Maps Infowindow error - always opened in one marker -
<script> function listing_mapa_init(){ var e=new google.maps.latlngbounds,t={ zoom:15, maptypeid:google.maps.maptypeid.roadmap }; var markers=[], places=[ [54.134363,37.581087,'scdasdcasdcv','september 11, 2017','/index.php?page=item&id=25','/img/no_photo.gif','check seller'], [54.134363,37.581087,'saefdefsd','september 11, 2017','/index.php?page=item&id=24','/img/no_photo.gif','check seller'], [55.755826,37.6173,'tru','september 11, 2017','/index.php?page=item&id=23','/img/no_photo.gif','124.00 usd'], [55.755826,37.6173,'mnu','september 11, 2017','/index.php?page=item&id=22','/img/no_photo.gif','check seller'], [52.287303,76.967402,'qwert','september 10, 2017','index.php?page=item&id=21','img/no_photo.gif','435654.00 usd'], [50.649917,38.401742,'asdf','september 10, 2017','/index.php?page=item&id=20','/img/no_photo.gif','435534.00 usd'], ]; var infowindow = new google.maps.infowindow({ maxwidth: 220 }); listing_mapa=new google.maps.map(document.getelementbyid("map_violet"),t); for(var o=new overlappingmarkerspiderfier(listing_mapa,{circlefootseparation:30}),a=0;a<places.length;a++){ var i=places[a],s=new google.maps.marker( {position:{lat:i[0],lng:i[1]},map:listing_mapa,draggable:!1,flat:!0,slug:i[2],href:i[4],img:i[5],dat:i[3],price:i[6]}); o.addmarker(s),markers.push(s),e.extend(s.position); o.addlistener("click",function(e,t){ infowindow.setcontent('<div id="iw-container"><div class="item__title"><a href="' + e.href + '">' + e.slug + '</a></div>' + '<div class="iw-content">' + '<a href="' + e.href + '"><img src="' + e.img + '" height="auto" width="210"></a>' + '<span class="item__date">' + e.dat + '</span>' + '<strong class="info__price">' + e.price + '</strong>' + '</div>' + '</div>'); infowindow.open(listing_mapa, s);}), o.addlistener("unspiderfy",function(e,t){n.resetviewport(),n.redraw()}); } var n=new markerclusterer(listing_mapa,markers,{maxzoom:0,zoomonclick:!1,gridsize:20,clusterclick:!0}); google.maps.event.addlistener(n,"clusterclick",function(e,t){var o=e.getmarkers(); return window.excludedfromclusters=[],o.foreach(function(e,t){window.excludedfromclusters.push(e.slug+"")}),n.resetviewport(),n.redraw(),settimeout(function(){var e=markers[markers.getindex(window.excludedfromclusters[window.excludedfromclusters.length-1],"slug")]; google.maps.event.trigger(e,"click"),window.excludedfromclusters=[]},100),!0}),google.maps.event.addlistener(listing_mapa,"zoom_changed",function(){zoomchangeboundslistener=google.maps.event.addlistener(listing_mapa,"bounds_changed",function(e){this.getzoom()>t.zoom&&1==this.initialzoom&&(this.setzoom(t.zoom),this.initialzoom=!1),google.maps.event.removelistener(zoomchangeboundslistener)})}),listing_mapa.initialzoom=!0,listing_mapa.fitbounds(e)} google.maps.event.adddomlistener(window,"load",listing_mapa_init); </script>
i use google maps api markerclusterer.js , overlappingmarkerspiderfier. works well, there small problem ... can not figure out clicking on marker, infowindow info different markers opens on 1 marker. grateful advice
Comments
Post a Comment