hybrid kill3r Posted October 15, 2009 Report Share Posted October 15, 2009 I have a question relating to Google Maps and CodeIgniter. I have dynamic pages with information about restaurants on them. All of this information is user created. I found a tutorial on Google Maps about using them with PHP and it only explains how to get maps about information I already have. Visitors can create their restaurant's profile page with a form and I highly doubt they will know their lattitude and longitude. How would I get this information based on the address they give us? Link to comment Share on other sites More sharing options...
yoursanjay Posted October 15, 2009 Report Share Posted October 15, 2009 Hi, You can get longitude & latitude information (based on address) from this site http://stevemorse.org/jcal/latlon.php as well as you can get the address (based on longitude & latitude) from here. Link to comment Share on other sites More sharing options...
hybrid kill3r Posted October 15, 2009 Author Report Share Posted October 15, 2009 I appreciate your input, but there's one problem. I need to be able to call the script within my PHP page on my server so that when the user submits the form on my site with their address in it, the latitude and longitude will automatically be calculated within the script. Link to comment Share on other sites More sharing options...
yoursanjay Posted October 15, 2009 Report Share Posted October 15, 2009 You can try the following code. But, change the Google Map API key to your site's API Key in the code section found as "key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A" <?phpif ($_REQUEST[where]) { $where = stripslashes($_REQUEST[where]); $whereurl = urlencode($where);// Note - Google key is domain specific!$location = file("http://maps.google.com/maps/geo?q=$whereurl&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");// Sample - $location[0]="200,8,51.369318,-2.133457"; list ($stat,$acc,$north,$east) = explode(",",$location[0]); $html = "Information for ".htmlspecialchars($where)."<br>"; $html .= "North: $north, East: $east<br>"; $html .= "Accuracy: $acc, Status: $stat<br>";} else { $html = "Space reserved for your report when form completed";}?><html><head><title>Postal Address to Latitude / Longitude</title></head><body>Enter a place name / address and a latitude and longitude isreturned.<hr><?php print $html; ?><hr><form method=post>Place: <input name=where size=40><input type=submit value=go></form></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 15, 2009 Report Share Posted October 15, 2009 You shouldn't need to give it lat/long, I've set up a few Google maps and was just able to create a placemark based on an entered address alone. The Google Maps developer center should have all of the code examples you need. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now