Skip to content

andyresta/google-map-api-from-server-side

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

google-map-api-from-server-side

Accessing google map from server side with php programming you can get location, lng, long, distance between two point, suggesstion from server side.

For What ?

several days, i'm handle client / company that using self local intranet. there employee cannot accessing internet, but this company need integrate with google map api. Just implemented in serverside that connect internet, Now client using intranet can integrated google map api.

Usage

<?php
  include 'GoogleMapApiServerSide.php';
  $gmap = $g=new GoogleMapApiServerSide();
  // and you can get call their method
  echo $g->get_detail_place_by_searchterm("monas jakarta indonesia","json");
  echo $g->get_detail_place_by_lnglat("-6.9843281,110.4093032","json");
  echo $g->get_suggestion_place("beach indonesia","json");
  echo $g->get_distance_two_place("-6.9843281,110.4093032","-6.9902904,110.4229372","json");
  // or you can use place_id
  echo $g->get_distance_two_place("place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE","place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE","json");
?>

Method description

get_detail_place_by_searchterm

you can get detail of place by your search term, And output like this below

{ "results" : [ { "address_components" : [ { "long_name" : "Gambir", "short_name" : "Gambir", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Gambir", "short_name" : "Gambir", "types" : [ "administrative_area_level_4", "political" ] }, { "long_name" : "Central Jakarta City", "short_name" : "Central Jakarta City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Jakarta", "short_name" : "Jakarta", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Gambir, Central Jakarta City, Jakarta, Indonesia", "geometry" : { "location" : { "lat" : -6.1753924, "lng" : 106.8271528 }, "location_type" : "GEOMETRIC_CENTER", "viewport" : { "northeast" : { "lat" : -6.174043419708497, "lng" : 106.8285017802915 }, "southwest" : { "lat" : -6.176741380291502, "lng" : 106.8258038197085 } } }, "place_id" : "ChIJLbFk59L1aS4RyLzp4OHWKj0", "plus_code" : { "compound_code" : "RRFG+RV Gambir, Central Jakarta City, Jakarta, Indonesia", "global_code" : "6P58RRFG+RV" }, "types" : [ "establishment", "point_of_interest" ] } ], "status" : "OK" }

get_detail_place_by_lnglat

you can get detail of place by your search term, And output like this below

{ "plus_code" : { "compound_code" : "2C85+7P Semarang, Semarang City, Central Java, Indonesia", "global_code" : "6P5G2C85+7P" }, "results" : [ { "address_components" : [ { "long_name" : "5", "short_name" : "5", "types" : [ "street_number" ] }, { "long_name" : "Jalan Yudistira", "short_name" : "Jl. Yudistira", "types" : [ "route" ] }, { "long_name" : "Pendrikan Kidul", "short_name" : "Pendrikan Kidul", "types" : [ "administrative_area_level_4", "political" ] }, { "long_name" : "Kecamatan Semarang Tengah", "short_name" : "Kec. Semarang Tengah", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Kota Semarang", "short_name" : "Kota Semarang", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Jawa Tengah", "short_name" : "Jawa Tengah", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] }, { "long_name" : "50131", "short_name" : "50131", "types" : [ "postal_code" ] } ], "formatted_address" : "Jl. Yudistira No.5, Pendrikan Kidul, Kec. Semarang Tengah, Kota Semarang, Jawa Tengah 50131, Indonesia", "geometry" : { "location" : { "lat" : -6.9843281, "lng" : 110.4093032 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : -6.982979119708498, "lng" : 110.4106521802915 }, "southwest" : { "lat" : -6.985677080291502, "lng" : 110.4079542197085 } } }, "place_id" : "ChIJR9wlO0-LcC4RP_lpOzTO8Eo", "plus_code" : { "compound_code" : "2C85+7P Semarang, Semarang City, Central Java, Indonesia", "global_code" : "6P5G2C85+7P" }, "types" : [ "establishment", "point_of_interest" ] }, { "address_components" : [ { "long_name" : "Museum Mandala Bakti", "short_name" : "Museum Mandala Bakti", "types" : [ "bus_station", "establishment", "point_of_interest", "transit_station" ] }, { "long_name" : "Barusari", "short_name" : "Barusari", "types" : [ "administrative_area_level_4", "political" ] }, { "long_name" : "Kecamatan Semarang Selatan", "short_name" : "Kec. Semarang Sel.", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Kota Semarang", "short_name" : "Kota Semarang", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Jawa Tengah", "short_name" : "Jawa Tengah", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Museum Mandala Bakti, Barusari, Kec. Semarang Sel., Kota Semarang, Jawa Tengah, Indonesia", "geometry" : { "location" : { "lat" : -6.984624999999999, "lng" : 110.409115 }, "location_type" : "GEOMETRIC_CENTER", "viewport" : { "northeast" : { "lat" : -6.983276019708498, "lng" : 110.4104639802915 }, "southwest" : { "lat" : -6.985973980291502, "lng" : 110.4077660197085 } } }, "place_id" : "ChIJHXTdOU-LcC4RdabCbMPT4Jo", "plus_code" : { "compound_code" : "2C85+5J Semarang, Semarang City, Central Java, Indonesia", "global_code" : "6P5G2C85+5J" }, "types" : [ "bus_station", "establishment", "point_of_interest", "transit_station" ] }, { "address_components" : [ { "long_name" : "Jalan Mgr Sugiyopranoto", "short_name" : "Jl. Nasional 14", "types" : [ "route" ] }, { "long_name" : "Barusari", "short_name" : "Barusari", "types" : [ "administrative_area_level_4", "political" ] }, { "long_name" : "Kecamatan Semarang Selatan", "short_name" : "Kec. Semarang Sel.", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Kota Semarang", "short_name" : "Kota Semarang", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Jawa Tengah", "short_name" : "Jawa Tengah", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] }, { "long_name" : "50245", "short_name" : "50245", "types" : [ "postal_code" ] } ], "formatted_address" : "Jl. Mgr Sugiyopranoto, Barusari, Kec. Semarang Sel., Kota Semarang, Jawa Tengah 50245, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.9841187, "lng" : 110.4091044 }, "southwest" : { "lat" : -6.9843582, "lng" : 110.4085197 } }, "location" : { "lat" : -6.9842377, "lng" : 110.4088124 }, "location_type" : "GEOMETRIC_CENTER", "viewport" : { "northeast" : { "lat" : -6.982889469708498, "lng" : 110.4101610302915 }, "southwest" : { "lat" : -6.985587430291503, "lng" : 110.4074630697085 } } }, "place_id" : "ChIJ4cXjMU-LcC4RxgdZLjSS0uI", "types" : [ "route" ] }, { "address_components" : [ { "long_name" : "Barusari", "short_name" : "Barusari", "types" : [ "administrative_area_level_4", "political" ] }, { "long_name" : "Semarang Selatan", "short_name" : "Semarang Selatan", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Semarang City", "short_name" : "Semarang City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Barusari, Semarang Selatan, Semarang City, Central Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.983228, "lng" : 110.409589 }, "southwest" : { "lat" : -6.9960001, "lng" : 110.402037 } }, "location" : { "lat" : -6.98944, "lng" : 110.4060998 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -6.983228, "lng" : 110.409589 }, "southwest" : { "lat" : -6.9960001, "lng" : 110.402037 } } }, "place_id" : "ChIJsSRg5EaLcC4RbnAJavxbC3E", "types" : [ "administrative_area_level_4", "political" ] }, { "address_components" : [ { "long_name" : "50245", "short_name" : "50245", "types" : [ "postal_code" ] }, { "long_name" : "Semarang Selatan", "short_name" : "Semarang Selatan", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Semarang City", "short_name" : "Semarang City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Semarang Selatan, Semarang City, Central Java 50245, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.9810213, "lng" : 110.4098358 }, "southwest" : { "lat" : -6.995976, "lng" : 110.4021071 } }, "location" : { "lat" : -6.9882368, "lng" : 110.4046103 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -6.9810213, "lng" : 110.4098358 }, "southwest" : { "lat" : -6.995976, "lng" : 110.4021071 } } }, "place_id" : "ChIJN-AyV0aLcC4Rm3Urw3vjD8I", "types" : [ "postal_code" ] }, { "address_components" : [ { "long_name" : "Semarang Selatan", "short_name" : "Semarang Selatan", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Semarang City", "short_name" : "Semarang City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Semarang Selatan, Semarang City, Central Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.9810949, "lng" : 110.44955 }, "southwest" : { "lat" : -7.011427899999999, "lng" : 110.40186 } }, "location" : { "lat" : -6.997927199999999, "lng" : 110.4291879 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -6.9810949, "lng" : 110.44955 }, "southwest" : { "lat" : -7.011427899999999, "lng" : 110.40186 } } }, "place_id" : "ChIJvcUXG2CLcC4ROGIgxMtxh-c", "types" : [ "administrative_area_level_3", "political" ] }, { "address_components" : [ { "long_name" : "Semarang", "short_name" : "Semarang", "types" : [ "locality", "political" ] }, { "long_name" : "Semarang City", "short_name" : "Semarang City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Semarang, Semarang City, Central Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.9421075, "lng" : 110.4854034 }, "southwest" : { "lat" : -7.1073521, "lng" : 110.348727 } }, "location" : { "lat" : -7.0051453, "lng" : 110.4381254 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -6.9421075, "lng" : 110.4854034 }, "southwest" : { "lat" : -7.1073521, "lng" : 110.348727 } } }, "place_id" : "ChIJTQINP02LcC4R8rlc2rkyBB4", "types" : [ "locality", "political" ] }, { "address_components" : [ { "long_name" : "Semarang City", "short_name" : "Semarang City", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Semarang City, Central Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -6.931527999999999, "lng" : 110.505358 }, "southwest" : { "lat" : -7.307201099999999, "lng" : 110.269127 } }, "location" : { "lat" : -6.9743984, "lng" : 110.4140692 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -6.931527999999999, "lng" : 110.505358 }, "southwest" : { "lat" : -7.307201099999999, "lng" : 110.269127 } } }, "place_id" : "ChIJaTWQ1q6LcC4Ry6CpRZSHMik", "types" : [ "administrative_area_level_2", "political" ] }, { "address_components" : [ { "long_name" : "Central Java", "short_name" : "Central Java", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Central Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -5.725698, "lng" : 111.6914889 }, "southwest" : { "lat" : -8.2116361, "lng" : 108.555502 } }, "location" : { "lat" : -7.150975, "lng" : 110.1402594 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -5.725698, "lng" : 111.6914889 }, "southwest" : { "lat" : -8.2116361, "lng" : 108.555502 } } }, "place_id" : "ChIJ3RjVnJt1ZS4RRrztj53Rd8M", "types" : [ "administrative_area_level_1", "political" ] }, { "address_components" : [ { "long_name" : "Java", "short_name" : "Java", "types" : [ "establishment", "natural_feature", "political" ] }, { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Java, Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : -5.8758139, "lng" : 114.6055719 }, "southwest" : { "lat" : -8.780560999999999, "lng" : 105.209808 } }, "location" : { "lat" : -7.614529200000001, "lng" : 110.7122465 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : -5.8758139, "lng" : 114.6055719 }, "southwest" : { "lat" : -8.780560999999999, "lng" : 105.209808 } } }, "place_id" : "ChIJNzIy0n6gei4RYO2r1lkc_oY", "types" : [ "establishment", "natural_feature", "political" ] }, { "address_components" : [ { "long_name" : "Indonesia", "short_name" : "ID", "types" : [ "country", "political" ] } ], "formatted_address" : "Indonesia", "geometry" : { "bounds" : { "northeast" : { "lat" : 6.216999899999999, "lng" : 141.0425 }, "southwest" : { "lat" : -11.1082999, "lng" : 94.7351 } }, "location" : { "lat" : -0.7892749999999999, "lng" : 113.921327 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 6.216999899999999, "lng" : 141.0425 }, "southwest" : { "lat" : -11.1082999, "lng" : 94.7351 } } }, "place_id" : "ChIJtwRkSdcHTCwRhfStG-dNe-M", "types" : [ "country", "political" ] } ], "status" : "OK" }

get_suggestion_place

you can get detail of place by your search term, And output like this below

{ "predictions" : [ { "description" : "Semarang, Semarang City, Central Java, Indonesia", "id" : "171c0a36496ce4894592a230589120b76cd931c3", "matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "place_id" : "ChIJTQINP02LcC4R8rlc2rkyBB4", "reference" : "ChIJTQINP02LcC4R8rlc2rkyBB4", "structured_formatting" : { "main_text" : "Semarang", "main_text_matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "secondary_text" : "Semarang City, Central Java, Indonesia" }, "terms" : [ { "offset" : 0, "value" : "Semarang" }, { "offset" : 10, "value" : "Semarang City" }, { "offset" : 25, "value" : "Central Java" }, { "offset" : 39, "value" : "Indonesia" } ], "types" : [ "locality", "political", "geocode" ] }, { "description" : "Semarang-Batang Toll Road, Jatisari, Batang Regency, Central Java, Indonesia", "id" : "99d29b68423831b489e29e62445c02853ac76db0", "matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "place_id" : "EkxTZW1hcmFuZy1CYXRhbmcgVG9sbCBSb2FkLCBKYXRpc2FyaSwgQmF0YW5nIFJlZ2VuY3ksIENlbnRyYWwgSmF2YSwgSW5kb25lc2lhIi4qLAoUChIJPWjLdNCKcC4RvK7kySWQVkASFAoSCUMqKCk5PnAuEUA4VuN2egIF", "reference" : "EkxTZW1hcmFuZy1CYXRhbmcgVG9sbCBSb2FkLCBKYXRpc2FyaSwgQmF0YW5nIFJlZ2VuY3ksIENlbnRyYWwgSmF2YSwgSW5kb25lc2lhIi4qLAoUChIJPWjLdNCKcC4RvK7kySWQVkASFAoSCUMqKCk5PnAuEUA4VuN2egIF", "structured_formatting" : { "main_text" : "Semarang-Batang Toll Road", "main_text_matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "secondary_text" : "Jatisari, Batang Regency, Central Java, Indonesia" }, "terms" : [ { "offset" : 0, "value" : "Semarang-Batang Toll Road" }, { "offset" : 27, "value" : "Jatisari" }, { "offset" : 37, "value" : "Batang Regency" }, { "offset" : 53, "value" : "Central Java" }, { "offset" : 67, "value" : "Indonesia" } ], "types" : [ "route", "geocode" ] }, { "description" : "Semarang, Central Java, Indonesia", "id" : "41c709713acf87f0ce799bc3585367c5a21af278", "matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "place_id" : "ChIJzQZQckSCcC4RsLxS43Z6AgM", "reference" : "ChIJzQZQckSCcC4RsLxS43Z6AgM", "structured_formatting" : { "main_text" : "Semarang", "main_text_matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "secondary_text" : "Central Java, Indonesia" }, "terms" : [ { "offset" : 0, "value" : "Semarang" }, { "offset" : 10, "value" : "Central Java" }, { "offset" : 24, "value" : "Indonesia" } ], "types" : [ "administrative_area_level_2", "political", "geocode" ] }, { "description" : "Semarang City, Central Java, Indonesia", "id" : "e2e05e92e92a67f92327460aaa07d0227ee33d19", "matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "place_id" : "ChIJaTWQ1q6LcC4Ry6CpRZSHMik", "reference" : "ChIJaTWQ1q6LcC4Ry6CpRZSHMik", "structured_formatting" : { "main_text" : "Semarang City", "main_text_matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "secondary_text" : "Central Java, Indonesia" }, "terms" : [ { "offset" : 0, "value" : "Semarang City" }, { "offset" : 15, "value" : "Central Java" }, { "offset" : 29, "value" : "Indonesia" } ], "types" : [ "administrative_area_level_2", "political", "geocode" ] }, { "description" : "Semarang Barat, Semarang City, Central Java, Indonesia", "id" : "9ad394261499dc507de781b6e47b41a271046db9", "matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "place_id" : "ChIJxTyq4SiLcC4RjzxrcS4DwT8", "reference" : "ChIJxTyq4SiLcC4RjzxrcS4DwT8", "structured_formatting" : { "main_text" : "Semarang Barat", "main_text_matched_substrings" : [ { "length" : 8, "offset" : 0 } ], "secondary_text" : "Semarang City, Central Java, Indonesia" }, "terms" : [ { "offset" : 0, "value" : "Semarang Barat" }, { "offset" : 16, "value" : "Semarang City" }, { "offset" : 31, "value" : "Central Java" }, { "offset" : 45, "value" : "Indonesia" } ], "types" : [ "administrative_area_level_3", "political", "geocode" ] } ], "status" : "OK" }

About

accessing google map from server side php

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages