Jump to content

google map API & XMLHttpRequest


Craig Hopson

Recommended Posts

hi can some one check this syntax of this cos i'm missing something it just dont workThe JS

downloadUrl("http://chsites.co.uk/track/inc/maploc.php?id='.$mapid.'&name='.$member['id'].'", function(data) {var xml = data.responseXML;                       var Center = xml.documentElement.getElementsByTagName("marker");               var map = new google.maps.Map(document.getElementById("map"), {                            center: new google.maps.LatLng(                         parseFloat(Center.getAttribute("lat")),                         parseFloat(Center.getAttribute("lon"))),                            zoom: 13,                            mapTypeId: google.maps.MapTypeId.ROADMAP,                            mapTypeControl: false,                            mapTypeControlOptions: {                            style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR                                 },                            navigationControl: true,                            navigationControlOptions: {                                    style: google.maps.NavigationControlStyle.SMALL                            }                    });}                    function downloadUrl(url, callback) {          var request = window.ActiveXObject ?                  new ActiveXObject("Microsoft.XMLHTTP") :                  new XMLHttpRequest;          request.onreadystatechange = function() {            if (request.readyState == 4) {                  request.onreadystatechange = doNothing;                  callback(request, request.status);            }          };          request.open("GET", url, true);          request.send(null);    }

The XML

<markers>         <marker lat="51.5589355" lon="0.1463353" speed="1.255" time="17:12:39 - 2012/12/04"/></markers>

Link to comment
Share on other sites

how doesn't it work? What debugging have you done to try and pinpoint the cause of your problem? At least give us something to work with when you present your problems.

Edited by thescientist
Link to comment
Share on other sites

sorry looking back i was vague. OK a simple Google map API V3 would be HTML

<script type="text/javascript"	  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC9drFQnsmuob_bO9wFITHv-5K2pM-lgD0&sensor=false"></script> <script type="text/javascript">var map = new google.maps.Map(document.getElementById("map"), {			    center: new google.maps.LatLng(LATITUDE,LONGITUDE),   //THIS MUST BE A POSITION (you understand)			    zoom: 13,			    mapTypeId: google.maps.MapTypeId.ROADMAP,			    mapTypeControl: false,			    mapTypeControlOptions: {			    style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR				 },			    navigationControl: true,			    navigationControlOptions: {				    style: google.maps.NavigationControlStyle.SMALL			    }		    });</script>

OK this will show a map with the center of the map whatever LATITUDE,LONGITUDE you put in i wish to update the map center every 10 seconds with new coordinates (the script in first post)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...