Hi All, I want to easily be able to take a postcode from a form field, pass it to the next page and then the pages converts in Javascript the postcode to coordinates. I am new to all this to am probably just being silly. I have tried geocoder.getLatLng but it doesn't return coordinates. Can anyone help please? (the code I am using is below and yes I know it is probably really silly!) I am trying to get the coordinates in to variable g, so I can just use an alert, and then once I have that, I know how to get that value and can work on it... Oh and I'm using my API key so request won't work on another domain but also on: http://www.hdcatering.co.uk/postcode_enter.cfm. Thanks :) Zena x
<!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" xmlns:v="urn:schemas- microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/ > <title>Google Maps API Example: Simple Geocoding</title> <script src="http://maps.google.com/maps? file=api&v=2.x&key=ABQIAAAAhKN3uUeGoeGMrK_zMNUbzhQ0OglE4sVGImVVrx8f6NqRdn7fwxSNTFh6QktXNe8V4FBY6hyzy6CqMg" type="text/javascript"></script> <script type="text/javascript"> var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); geocoder = new GClientGeocoder(); } } function showAddress(address) { if (geocoder) { var g = geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } alert (g); } </script> </head> <body onload="initialize()" onunload="GUnload()"> <form action="#" onsubmit="showAddress(this.address.value); return false"> <p> <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" /> <input type="submit" value="Go!" /> </p> <div id="map_canvas" style="width: 500px; height: 300px"></div> </form> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
