Note: This service requires your project to have an associated billing information.
Make sure to ENABLE this Places API in your google map console dashboard.You can get for the details of a place by calling the GetPlaceDetails method of the map object like this:
place_id |
String Required. The id of the place that you want to search. Useful when you use the FindPlaceByTextQuery which returns the place id. |
fields |
String Optional. A comma separated options on the fields that you want to receive in the callback. Defaults are "name, geometry.location, formatted_address". |
callback |
Function Required. The function where to pass the result in the sequence (error, result). |
List of available fields:
address_component, adr_address, business_status, formatted_address, geometry, icon, name, permanently_closed, photo, place_id, plus_code, type, url, utc_offset, vicinity, formatted_phone_number, international_phone_number, opening_hours, website, price_level, rating, review, user_ratings_total
{ "address_components" : [ { "long_name" : "5", "short_name" : "5", "types" : [ "floor" ] }, { "long_name" : "48", "short_name" : "48", "types" : [ "street_number" ] }, { "long_name" : "Pirrama Road", "short_name" : "Pirrama Rd", "types" : [ "route" ] }, { "long_name" : "Pyrmont", "short_name" : "Pyrmont", "types" : [ "locality", "political" ] }, { "long_name" : "Council of the City of Sydney", "short_name" : "Sydney", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New South Wales", "short_name" : "NSW", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Australia", "short_name" : "AU", "types" : [ "country", "political" ] }, { "long_name" : "2009", "short_name" : "2009", "types" : [ "postal_code" ] } ], "adr_address" : "5, \u003cspan class=\"street-address\"\u003e48 Pirrama Rd\u003c/span\u003e, \u003cspan class=\"locality\"\u003ePyrmont\u003c/span\u003e \u003cspan class=\"region\"\u003eNSW\u003c/span\u003e \u003cspan class=\"postal-code\"\u003e2009\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eAustralia\u003c/span\u003e", "formatted_address" : "5, 48 Pirrama Rd, Pyrmont NSW 2009, Australia", "formatted_phone_number" : "(02) 9374 4000", "geometry" : { "location" : { "lat" : -33.866651, "lng" : 151.195827 }, "viewport" : { "northeast" : { "lat" : -33.8653881697085, "lng" : 151.1969739802915 }, "southwest" : { "lat" : -33.86808613029149, "lng" : 151.1942760197085 } } }, "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7", "international_phone_number" : "+61 2 9374 4000", "name" : "Google", "place_id" : "ChIJN1t_tDeuEmsRUsoyG83frY4", "rating" : 4.5, "reference" : "CmRSAAAAjiEr2_A4yI-DyqGcfsceTv-IBJXHB5-W3ckmGk9QAYk4USgeV8ihBcGBEK5Z1w4ajRZNVAfSbROiKbbuniq0c9rIq_xqkrf_3HpZzX-pFJuJY3cBtG68LSAHzWXB8UzwEhAx04rgN0_WieYLfVp4K0duGhTU58LFaqwcaex73Kcyy0ghYOQTkg", "reviews" : [ { "author_name" : "Robert Ardill", "author_url" : "https://www.google.com/maps/contrib/106422854611155436041/reviews", "language" : "en", "profile_photo_url" : "https://lh3.googleusercontent.com/-T47KxWuAoJU/AAAAAAAAAAI/AAAAAAAAAZo/BDmyI12BZAs/s128-c0x00000000-cc-rp-mo-ba1/photo.jpg", "rating" : 5, "relative_time_description" : "a month ago", "text" : "Awesome offices. Great facilities, location and views. Staff are great hosts", "time" : 1491144016 } ], "types" : [ "point_of_interest", "establishment" ], "url" : "https://maps.google.com/?cid=10281119596374313554", "utc_offset" : 600, "vicinity" : "5, 48 Pirrama Road, Pyrmont", "website" : "https://www.google.com.au/about/careers/locations/sydney/" }
From the result above, the value of the fields pass into the method are "address_components, adr_address, formatted_address, formatted_phone_number, geometry, icon, id, international_phone_number, name, place_id, rating, reference, reviews, types, url, utc_offset, vicinity, website". The result is an object whose properties are the fields you pass into the method. Make sure to check first if error is true or false. If error is true, then the result is the error message.
app.LoadPlugin("MapView"); function OnStart() { lay = app.CreateLayout("Linear", "VCenter, FillXY"); var apiKey = "AIzaSyD2eHntKEmh272p3ac6YjWPbPkwo3m2mck"; map = app.CreateMapView(apiKey, 0.9, 0.5, 7.0689323, 125.6114588, 13); map.SetOnReady(MapOnReady); lay.AddChild(map); app.AddLayout(lay); } function MapOnReady() { var placeId = "ChIJN1t_tDeuEmsRUsoyG83frY4"; map.GetPlaceDetails(placeId, "name,geometry", OnResult); } function OnResult(error, result) { if(error) { alert(error); return; } var loc = result.geometry.location; marker = map.CreateMarker(loc.lat, loc.lng); marker.AddListener("click", "OnMarkerClick"); var content = "Name: "+data.result.name; infowindow = map.CreateInfoWindow(content); map.PanTo(loc.lat, loc.lng); } function OnMarkerClick() { infowindow.Open(marker); }