It is my first question. I personally find this website awesome and helped me a lot so many times :)
Now I have a question that is not resolved :P
I am developing a website using the Google maps API. It is expected that i will have too many markers in the future, so I thought about 2 ways of solve it:
I tried to do both of them and with both i have a problem
If i use markerclusterer, it works fine, but i cannot open an html windows when i press on a single marker
for(var i = 0; i < 50; i += 0.1) {
var marker = new GMarker(new GLatLng(59.0 + i, 13.80 + i));
markers.push(marker);
}
This is the code i use for pushing the markers into the array, so i cannot add the event, well, i can but only applies to the last one.
Any idea?
Thanks in advance!!!
Try something like this to get the content for an individual marker when clicked. You just need to add the marker to your cluster and it should be ok.
function load_content(marker, id){
$.ajax({
url: '/map/getMarkerWindow/' + id,
success: function(data){
infowindow.setContent(data);
infowindow.open(map, marker);
}
});
}
for(var i = 0; i < 50; i += 0.1) {
var marker = new GMarker(new GLatLng(59.0 + i, 13.80 + i));
marker = new google.maps.Marker({
position: new google.maps.LatLng(59.0 + i, 13.80 + i),
clickable: true,
id:i
});
google.maps.event.addListener(marker, "click", function() {
infowindow.close();
load_content(this, this.id);
});
markers.push(marker);
}