Kevin
Kevin

Reputation: 13226

Create Gmap Link from an address

Given a street, city, lat/long, and zip, how do you create an anchor link to a Google Map?

Following a Gmap result, I tried to mimic the link it gave. So far, I have tried:

$street = str_replace(' ', '+', $location['street']);
$street = str_replace('#', '%23', $street);
$city = str_replace(' ', '+', $location['city']);
$state = str_replace(' ', '+', $location['state']);
$zip = $location['zip'];
$lat = $location['lat'];
$long = $location['long'];

$map = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='.$street.'+'.$city.'+'.$state.'&sll='.$lat.','.$long.'&ie=UTF8&hq=&hnear='.$street.',+'.$city.',+'.$state.',+'.$zip.'&ll='.$lat.','.$long;

Sometimes it works, other times I get "We could not understand your request". Does anyone know of a way to make this work for any result?

Upvotes: 3

Views: 4625

Answers (1)

Galen
Galen

Reputation: 30170

I've always simplified it down to just the query (q) and i've never had an issue

http://www.google.com/maps?q=address(tooltip/infowindow title)

whatever you put in the () will be the tooltip text and the title for the infowindow

Upvotes: 5

Related Questions