Back

Find Places

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 search for a place by calling the FindPlaceByTextQuery or FindPlaceByPhoneNumber method of the map object like these:

 map.FindPlaceByTextQuery(query, lat, lng, radius, fields, callback)
 map.FindPlaceByPhoneNumber(number, fields, callback)


query String
Required. The text query that you want to search (example: "pizza" or "hotel")
number String
Required. The Phone number must be in international format (the country code followed by the phone number itself, removed the plus sign ("+") prefix).
lat Number
Optional. The latitude of the center coordinate from where to start searching
lng Number
Optional. The longitude of the center coordinate from where to start searching.
radius Number
Optional. The radius in meters of the search within where to search the result. Default is 5000
fields String
Optional. A comma separated options on the fields that you want to receive in the callback. Default are "name, geometry, place_id".
callback Function
Required. The function where to pass the result in the sequence (error, result).

List of available fields:
business_status, formatted_address, geometry, icon,name, permanently_closed, photos, place_id, plus_code, types, open_now, price_level, rating, user_ratings_total

Sample result

[
  {
     "formatted_address" : "140 George St, The Rocks NSW 2000, Australia",
     "geometry" : {
        "location" : {
           "lat" : -33.8599358,
           "lng" : 151.2090295
        },
        "viewport" : {
           "northeast" : {
              "lat" : -33.85824767010727,
              "lng" : 151.2102470798928
           },
           "southwest" : {
              "lat" : -33.86094732989272,
              "lng" : 151.2075474201073
           }
        }
     },
     "name" : "Museum of Contemporary Art Australia",
     "opening_hours" : {
        "open_now" : false,
        "weekday_text" : []
     },
     "photos" : [
        {
           "height" : 2268,
           "html_attributions" : [
              "\u003ca href=\"https://maps.google.com/maps/contrib/113202928073475129698/photos\"\u003eEmily Zimny\u003c/a\u003e"
           ],
           "photo_reference" : "CmRaAAAAfxSORBfVmhZcERd-9eC5X1x1pKQgbmunjoYdGp4dYADIqC0AXVBCyeDNTHSL6NaG7-UiaqZ8b3BI4qZkFQKpNWTMdxIoRbpHzy-W_fntVxalx1MFNd3xO27KF3pkjYvCEhCd--QtZ-S087Sw5Ja_2O3MGhTr2mPMgeY8M3aP1z4gKPjmyfxolg",
           "width" : 4032
        }
     ],
     "rating" : 4.3
  }
]

From the result above, the value of the fields pass into the FindPlaceByTextQuery method are "formatted_address, geometry, name, opening_hours, photos, rating". The result is actually an array of candidates of the place being search. Make sure to check first if error is true or false. If error is true, then the result is the error message.

FindPlaceByTextQuery example

app.LoadPlugin("MapView");

var lat = 7.0689323;
var lng = 125.6114588;

function OnStart() {
    lay = app.CreateLayout("Linear", "VCenter, FillXY");
        
        var apiKey = "AIzaSyD2eHntKEmh272p3ac6YjWPbPkwo3m2mck";
        
        map = app.CreateMapView(apiKey, 0.9, 0.5, lat, lng, 13);
        map.SetOnReady(MapOnReady);
        lay.AddChild(map);

    app.AddLayout(lay);
}
function MapOnReady() {
    var query = "Museum of Contemporary Art Australia";
    map.FindPlaceByTextQuery(query, lat, lng, null, null, OnResult);
}
function OnResult(error, result) {
    if(error) {
        var errMsg = result;
        app.ShowPopup(errMsg);
    }
    else {
        app.ShowPopup(result);
        
        //access the first result
        loc = result[0].geometry.location;
        marker = map.CreateMarker(loc.lat, loc.lng);
        map.PanTo(loc.lat, loc.lng);
    }
}
Copy    Run