Create a Gmap link from an address

Given street, city, lat / long and zip, how do you create a Google map snap?

After the Gmap result, I tried to reproduce the link that 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, sometimes I get "We could not understand your request." Does anyone know a way to make this work for any result?

+3
source share
1 answer

I always simplified it only to query (q), and I never had a problem

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

all you put in () will be a tooltip text and title for infowindow

+4
source

Source: https://habr.com/ru/post/1773036/


All Articles