Jump to content

Google Maps


hybrid kill3r
 Share

Recommended Posts

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

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

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
 Share

×
×
  • Create New...