Using google maps, im thinking var address= is converted to latitude longitutde in this code somewere , i would like to be able to echo that if possible like I do php so that I can save it into a database... someone tell me its possible as I dont understand javascript at all. <script src="http://maps.google.com/maps?file=api&v=2&key=mykey" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var geocoder; var map; var address = "1145 East Main Street, Salem, VA"; function load() { map = new GMap2(document.getElementById("map")); geocoder = new GClientGeocoder(); geocoder.getLocations(address, addToMap); } function addToMap(response) { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(point, 15); marker = new GMarker(point); map.addOverlay(marker); } //]]> </script> Edit..... i found that place.Point.coordinates[1] and place.Point.coordinates[0] are both the longitute and latitude i need but how to make it output to something like myphp?latitude=place.Point.coordinates[1]&longitude=place.Point.coordinates[0]
You can send an AJAX request to server side (php) script, that will save coordinates to DB. Something like this (I used jQuery library (http://docs.jquery.com/Ajax/jQuery.post) to simplify code) $.post("saver.php", { latitude: place.Point.coordinates[1], longitude: place.Point.coordinates[0] }, function(data){ alert("Data Saved"); }); Code (markup): In PHP script you can access values from $_POST['latitude'] and $_POST['longitude']