Current location: Hot Scripts Forums » Programming Languages » PHP » PHP/MySQL & Google maps


PHP/MySQL & Google maps

Reply
  #1 (permalink)  
Old 06-10-09, 06:25 PM
Aarchaic Aarchaic is offline
Newbie Coder
 
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
PHP/MySQL & Google maps

hey guys

I have a quesion regarding PHP/MySQL and google Maps.

i'm working on a section on our new updated site where clubs/venues/restaurants and so forth and even users can register and be able to see what places is near them and how far they are from one another.

what i need to do is take the address the user has put in work out the coordinates for the user and save it in a database.

Has anyone worked with this yet?

either i'm not looking hard enough, or i'm missing what i need to do.
Reply With Quote
  #2 (permalink)  
Old 06-10-09, 06:54 PM
Aarchaic Aarchaic is offline
Newbie Coder
 
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I just found the solution!

here is how its done....

PHP Code:


<?php
$address
=""//address looking for
$key=""// google map key that needs to be generate for your site by google maps
$file file_get_contents("http://maps.google.com/maps/geo?output=xml&q=".
urlencode($address). "&key=".GOOGLE_MAP_KEY);

/**
* A Bug? It says it's utf-8, but it's really not :(
*/

$xml iconv("ISO-8859-1""UTF-8"$file);
$xml simplexml_load_string($xml);

if (!
is_object($xml))
throw new 
Exception("Could not connect to geocode server. Sent argument: $address");

if (
$xml->Response->Status->code == 200) {

$coordinates = (string) $xml->Response->Placemark->Point->coordinates;
list(
$latitude$longitude) = explode(','$coordinates);

echo (
"lat: $latitude - lon: $longitude");
} else {
throw new 
Exception("could not find $address");
}

?>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google maps Dimka JavaScript 1 02-24-09 02:03 PM
Google maps api + panoramio gckmac Script Requests 0 06-23-08 09:08 PM
Something like Google Maps for my own maps... caro23 Script Requests 0 02-13-08 02:13 AM
web app: Hide/Unhide Menu (Google Maps & Google Reader) cmysites Script Requests 0 11-08-07 11:37 PM
How to get Indexed in Google Quickly rorycanyon General Advertisements 3 03-21-07 09:11 AM


All times are GMT -5. The time now is 08:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.