fikka
09-04-2007, 04:10 PM
Hi
I'm trying to do a very simple thing here: I have the map with the markers and clusters on it and I want to open an info window if user clicks on them. For some reason openInfoWindowHtml doesn't work, I cannot understand why.
So here is my java script, may be you'll see what's wrong here?
Thank you
var map;
var centerLatitude = 0;
var centerLongitude = 0;
var startZoom = 1;
//Create an icon for the clusters
skipped
//create an icon for the pins
skipped
function init() {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
updateMarkers();
GEvent.addListener(map,'moveend',function() {
updateMarkers();
});
}
function updateMarkers() {
//remove the existing points
map.clearOverlays();
//create the boundry for the data to provide
//initial filtering
skipped
//log the URL for testing
GLog.writeUrl('map_search.php?'+getVars);
//retrieve the points
var request = GXmlHttp.create();
request.open('GET', 'map_search.php?'+getVars, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var jscript = request.responseText;
var points;
eval(jscript);
//create each point from the list
for (i in points) {
var point = new GLatLng(points[i].lat,points[i].lng);
var marker = createMarker(point,points[i].type,points[i].description);
map.addOverlay(marker);
}
}
}
request.send(null);
}
function createMarker(point, type, description) {
//create the marker with the appropriate icon
if(type=='c') {
var marker = new GMarker(point,iconCluster,true);
} else {
var marker = new GMarker(point,iconSingle,true);
}
// open info window on click
GEvent.addListener(marker,'click',function() {
var markerHtml = description;
marker.openInfoWindowHtml(markerHtml);
});
return marker;
}
window.onload = init;
I'm trying to do a very simple thing here: I have the map with the markers and clusters on it and I want to open an info window if user clicks on them. For some reason openInfoWindowHtml doesn't work, I cannot understand why.
So here is my java script, may be you'll see what's wrong here?
Thank you
var map;
var centerLatitude = 0;
var centerLongitude = 0;
var startZoom = 1;
//Create an icon for the clusters
skipped
//create an icon for the pins
skipped
function init() {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
updateMarkers();
GEvent.addListener(map,'moveend',function() {
updateMarkers();
});
}
function updateMarkers() {
//remove the existing points
map.clearOverlays();
//create the boundry for the data to provide
//initial filtering
skipped
//log the URL for testing
GLog.writeUrl('map_search.php?'+getVars);
//retrieve the points
var request = GXmlHttp.create();
request.open('GET', 'map_search.php?'+getVars, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var jscript = request.responseText;
var points;
eval(jscript);
//create each point from the list
for (i in points) {
var point = new GLatLng(points[i].lat,points[i].lng);
var marker = createMarker(point,points[i].type,points[i].description);
map.addOverlay(marker);
}
}
}
request.send(null);
}
function createMarker(point, type, description) {
//create the marker with the appropriate icon
if(type=='c') {
var marker = new GMarker(point,iconCluster,true);
} else {
var marker = new GMarker(point,iconSingle,true);
}
// open info window on click
GEvent.addListener(marker,'click',function() {
var markerHtml = description;
marker.openInfoWindowHtml(markerHtml);
});
return marker;
}
window.onload = init;