Closed Salomoun closed 7 years ago
Hi there. Either I didn't understand you question, or this is really a general Google Maps API question and not connected to this library. If you have a question about the OverlappingMarkerSpiderfier, please clarify, otherwise I suggest you check out StackOverflow or some other appropriate venue.
Hi. I would like to open my link inserted within info window. And in this case is particularly connected with this library. I know, how can I accomplish it with standard Google api. But with your great library, I have to use two click listeners. One for icon behavior and second one for infowindow, and I’m not sure, if my solution is correct. So, my humble question is, could I use something like this? It works, but I’m not sure with using click and spider_click solution. Don’t look at the var content – it is only for testing. Thanx a lot for your work!
` for (var i = 0, len = window.mapData.length; i < len; i++) { (function () { // make a closure over the marker and marker data var markerData = window.mapData[i]; // e.g. { lat: 50.123, lng: 0.123, text: 'XYZ' } var marker = new google.maps.Marker({ position: markerData, url: markerData.brslink, icon: markerData.brsico }); //
var content = '<a href="' + marker.url + '" class="maplink">' + marker.url + '<br>' + markerData.text + '</a>'
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'spider_click', (function (marker, content, infowindow) {
return function () {
infowindow.setContent(content);
infowindow.open(map, marker);
/* keep the handle, in order to close it on next click event */
infos[0] = infowindow;
};
})(marker, content, infowindow));
google.maps.event.addListener(marker, 'click', iwClose);
oms.addMarker(marker, function (e) {
iw.setContent(markerData.text);
iw.open(map, marker);
});
})();`
You have one listener too many, and you're unnecessarily creating an InfoWindow on every pass through the loop.
I think all you need to do is adapt the simple demo, changing the line where the content is assigned to the InfoWindow: iw.setContent(markerData.text);
.
Hi. How can I insert active link in every sepate marker - for example into text, or in description - or make clickable whole info window? Thanx