Google Maps API get photo_reference from nearbysearch JSON -


good morning,

at moment trying build website shows 1 photo nearby search in google map api. in example trying have alert photo_reference need display photo later cannot figure out how photo_reference id. current not working code:

var url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=myapikey"; $.getjson(url, function (data) {     var photo_reference = data.results[0].photos[0].photo_reference;     alert(photo_reference);  }); 

i hope out there can me one.

here photo_reference trying get:

{    "html_attributions" : [],  "results" : [      {      "geometry" : {         "location" : {            "lat" : -33.86879,            "lng" : 151.194217         }      },      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",      "id" : "21a0b251c9b8392186142c798263e289fe45b4aa",      "name" : "rhythmboat cruises",      "opening_hours" : {         "open_now" : false,         "weekday_text" : []      },      "photos" : [         {            "height" : 467,            "html_attributions" : [],            "photo_reference" : "cnrnaaaauydlxxeaepo7jaun863gnm1extumabhalxdl1hsrph6bwvtbxo_3zxrz--ovgxbynzjr8m5imwqtlydoupfsnwxrjjwtrnzmpcsuexbmofahnff1xbwgeacv-skv0qorkv7b0jet_cp0dmxnd-h3jhiqft0a9raxymhqob9valapsrourrccxha7ddvxbxd8fwoh7ul_jjq",            "width" : 573         }      ], 

edit: seems working http , not https ... not looking work around.

you can refer developer's guide: https://developers.google.com/places/webservice/photos#place_photo_requests

which suggested can photo by:

https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=cnrtaaaatlznl354rwp_9ukbq_5psy40texxepv4oalgp4qnekdirkyse7rpxygd9d_uj1rvsqdwt4orz4qryajnpfx7rzqqmlzw2h2e2y5ikmuz7oud_slchxyq1yl4kbkuv3qtwgtk0a6qbgh87gb3sscrhriqig2rrmu_jf4tenr9wgs_yxoussdryjwmrnfeehsgsc3fyhnllbu&key=api_key

=-=-=-=-=- edit -=-=-=-=-=
should not use google maps api web services on client side web app, violates access-control-allow-origin policy.

the correct way use places library in google maps javascript api shown here.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -