[Google Maps API v2] Update marker from json file
Im trying to update the marker from a json format but it is not
working.
Can you please help me, here is the code below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>Map test</title>
<h2>Google Map</h2>
<script src="http://maps.google.com/maps?
file=api&v=2&key=ABQIAAAAR0TWf73rulOP_SnETQPFKxRj5djmSsmVAgDaRb1psFcJlThRhxSjxifqM96NjrBsBn2XrZWSE-
QQqQ"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
jsonData =
{"markers": [
{"lat":"-29.86868", "lng":"30.981588"},
{"lat":"-29.85368", "lng":"30.980927"},
{"lat":"-29.86100", "lng":"30.980755"}
],}
var map = null;
var route = null;
var Marker = null;
var point = null;
var count = 0;
var delay = 5000;
var loops = 5;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(-29.870879, 30.977258), 10);
var jsonData = eval('(' + doc + ')');
var point = new GLatLng(jsonData.markers[count].lat,
jsonData.markers[count].lng);
Marker = new GMarker(point);
map.addOverlay(Marker);
route = setTimeout("moveIT()", 4000);
}
}
function moveIT() {
count++;
if(count > jsonData.makers.length - 1) {
count = 0;
loops--;
}
point = new GLatLng(jsonData.markers[count].lat,
jsonData.markers[count].lng);
Marker.setLatLng(point);
if (loops > 0)
{
route = setTimeout("moveIT()", delay);
}
}
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 800px; height: 600px"></div>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home