1
kerkyra
xajax and google maps
  • 2008/4/23 12:30

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


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?
whttp://www.guidemap.gr - Beta is out...

Login

Who's Online

479 user(s) are online (71 user(s) are browsing Support Forums)


Members: 0


Guests: 479


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits