1
hi,
i'm trying to make google maps markers to load dynamicaly using xajax (followed a tutorial by kaotik regarding xajax).
I have made a function to load the markers and respond with xml using xajax.
the respond i take through xajax after checking a check box is the following.
Quote:
which means that the code works...
now i have a js script function which is supposed to parse those data and show the correspinding marker on the map.
the code is the following..
Quote:
function loadMarkers(locid,cid) {
xajax.request.onreadystatechange = function() {
if (xajax.request.readyState == 4) {
var xmlDoc = GXml.parse(xajax.request.responseText);
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
ii = 0;
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lon = parseFloat(markers[i].getAttribute("lon"));
var locid = parseFloat(markers[i].getAttribute("locid"));
var id = parseFloat(markers[i].getAttribute("id"));
var cid = parseFloat(markers[i].getAttribute("cid"));
var pid = parseFloat(markers[i].getAttribute("pid"));
var tooltip = markers[i].getAttribute("tooltip");
var image = markers[i].getAttribute("image");
var point = new GLatLng(lat,lon);
var marker = createMarkersVisible(point,cid,pid,lid,tooltip,image);
}
}
}
}
function createMarkersVisible(point,cid,pid,lid,tooltip,img) {
//var image=img;
var icon = new GIcon();
icon.image = img;
//icon.shadow = "";
icon.iconSize = new GSize(20, 20);
icon.shadowSize = new GSize(19, 20);
icon.iconAnchor = new GPoint(20, 19);
icon.infoWindowAnchor = new GPoint(20, 8);
// creation marker
var marker = new GMarker(point,{icon:icon, title:tooltip});
marker.cid = cid;
marker.pid = pid;
marker.lid = lid;
// The new marker "mouseover" listener -shows the tooltip
// ====== The new marker "mouseover" and "mouseout" listeners ======
//GEvent.addListener(marker,"mouseover", function() { showTooltip(marker);});
//GEvent.addListener(marker,"mouseout", function() { tooltip.style.visibility="hidden"});
GEvent.addListener(marker,"click", function() {
location.href="visit.php?cid="+marker.cid+"&lid="+marker.lid;
});
gmarkers.push(marker);
map.addOverlay(marker,icon);
return marker;
}
these two functions should show the markers but yet the markers are not showing. i suspect there is something wrong with the parsing of the data from the response.
Anybody has any suggestions or ideas?