KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
this is my simple code I'm using in a test page: but it takes ages to find the address...how come? am i doing something wrong? <script src="http://maps.google.com/maps?hl=it&file=api&v=2&sensor=true&key=*xxxxxx*" type="text/javascript"></script> <script type="text/javascript"> var map; var geocoder; function addAddressToMap(response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); document.getElementById('address').innerHTML = place.address; } } function searchGeolocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { geocoder = new GClientGeocoder(); document.getElementById('latitude').innerHTML = position.coords.latitude; document.getElementById('longitude').innerHTML = position.coords.longitude; coordinates = position.coords.latitude+","+position.coords.longitude; geocoder.getLocations(coordinates, addAddressToMap); }); }else { document.getElementById('latitude').innerHTML = "Unknown"; document.getElementById('longitude').innerHTML = "Unknown"; document.getElementById('address').innerHTML = "Unknown"; alert("I'm sorry, but geolocation services are not supported by your browser."); } } </script> <br/> latitude = <div id="latitude">loading...</div> <br/> longitude = <div id="longitude">loading...</div> <br/> address = <div id="address">loading...</div> <br/> <script type="text/javascript
Tags (comma-separated)
Save Edits
Cancel