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

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.

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.

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)

Tags

Similar posts

  • kanika

    nice tutorial…Is there any way if you could advise how to display directions to locations. Thanks in advance.

  • please teach me how to show location ‘saved’ from database 🙂

    just send me an email agungrajibnugraha@gmail.com 🙂 please ^_^

  • Manvi Agarwal

    Thanx…

  • Robert Banister

    On your LINE 21 in process.php, you need to CORRECT the following
    $add to $address…dugh

    $geocode = file_get_contents(‘http://maps.google.com/maps/api/geocode/json?address=’.$add.’,+’.$city.’,+’.$state.’,+’.$country.’&sensor=false’);
    to

    $geocode = file_get_contents(‘http://maps.google.com/maps/api/geocode/json?address=’.$address.’,+’.$city.’,+’.$state.’,+’.$country.’&sensor=false’);