Hey all,

Here is what I want to do. Create a map with markes from a database
and when a marker is click the information will be get dynamic at the
click time. I have to many information to put into the marker to
create it at the start – the database search will take to long time.

I have a php function to get the data – first as a xml list to get
position of the markers and a ID - and sekund to getting the data when
a marker is clicked (as html code)

It all works with just one marker and not using array but when I use
the array it fails

So, how to use dynamic javascript vars with the api ??


Code that get the data by using PHP – working fine in IE, firefox and
Safai just for FYI
-----------------
(function(){if(window.XMLHttpRequest)return;var o=null,s,
 a=["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.
3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
 for(var i=0,j=a.length;i<j;s=a[i],i++){try{if(o=new ActiveXObject(s))
break}
 catch(e){}}window.XMLHttpRequest=o?function(){return new ActiveXObject
(s)}:null;o=null})()

function load_php(type,id) {
var nocache = Math.random();
var oHttp = new XMLHttpRequest();
oHttp.open("get", "googlemaps_getdata.php?type="+type+"&id="+id
+"&nocache="+nocache, false);
oHttp.onreadystatechange = function(){};
oHttp.send(null);
return oHttp.responseText;
} // end function load_php


Code that gets the data and setup the dynamic on the fly getting of
final data.
------------------------
function initialize() {

if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(55.684343, 12.590976), 12);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
map.enableContinuousZoom();

var data = load_php("list","");
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var aid = parseFloat(markers[i].getAttribute("id"));
var themarker = new Array();
themarker[i] = new GMarker(new GLatLng(lat, lng));
map.addOverlay(themarker[i]);

GEvent.addListener(themarker[i], "click", function() {
themarker[i].openInfoWindow(load_php("arbplads",aid));
})

} // endfor
} // endif GBrowserIsCompatible()
} // end function initialize()

The xml that the php generates:
---------------------------
<markers>
<marker lat="55.680698" lng="12.594033" id="1564" ran="" />
<marker lat="55.696973" lng="12.565956" id="15018" ran="" />
</markers>

Any idea’s ??

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to