Skip links

Display each users location in google map using address in PHP and Java Script

Display each users locations in the google map after submitting his addresses using php and java script.This is displaying using location latitude and longitude.That is marked by red bubble.You can customize map types as ROADMAP,SATELLITE,HYBRID or TERRAIN, displaying controls….etc.

This is the html form.User submit his address using this form.

Address :
City :
State :
Country :
Zip code :

process.php file.This is generate map after submitting details.First it submit address details to the google map and get the response.It contains latitude and longitude of the given address.Then generate google map using this latitude and longitude.
Here is a process.php full page.

Get Location Map using Address

status == 'OK'){ // Check if address is available or not
	echo "
"; echo "Latitude : ".$latitude = $output->results[0]->geometry->location->lat; //Returns Latitude echo "
"; echo "Longitude : ".$longitude = $output->results[0]->geometry->location->lng; // Returns Longitude } else { echo "Sorry we can't find this location.Check the details again!"; } ?>

The following map types are supported.

  • ROADMAP displays the normal, default 2D tiles of Google Maps.
  • SATELLITE displays photographic tiles.
  • HYBRID displays a mix of photographic tiles and a tile layer for prominent features (roads, city names).
  • TERRAIN displays physical relief tiles for displaying elevation and water features (mountains, rivers, etc.).

How to change map type

mapTypeId: google.maps.MapTypeId.ROADMAP replace ROADMAP your map type.
Example, display SATELLITE map, mapTypeId: google.maps.MapTypeId.SATELLITE

How to change map size.

change zoom: 14 to your value. (5 wide area displaying, 20-small area displaying by zooming)
View Demo

Download Display location using address Example (3 KB)