Add photo to place with Google Places API - google-places-api

I noticed that GET request on place search with Google Places API sometimes respond with a photos object which looks alike this:
"photos" : [
{
"height" : 270,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110354877626525435377/photos\"\u003eFranck Moulinier\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAD_gs_sDA2mV2N4IAc-3LrIxEQU0Db0jo3Mizk4MDFWYe1IM0BCD03jr1v2QCg24XqfkOs5_ztg3kGQVCd8YNr_H97jkFC970-oHP86miLvXvHDh5skCwVpWsftZ-MxqxX4_l8WYSEaGgUcfnS5KL03-DBA8-S6HCo_gbYC9jF7bEhDHZMsHhbgom825iS-av2LTGhQ6LcPSmy0g7PheNuiFNAlGiKUXOQ",
"width" : 270
},
{
"height" : 518,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110354877626525435377/photos\"\u003eFranck Moulinier\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAEu8V-GUdxdJY8W04iZVTVdB3k7LdHxMpLZh24IIIJ88zm_CJkLSKwhj4RSqTGAH8xtTFRAKIiHh_l2GyZx8g2OUojN0lNOUtAiUE7zprFT3rJ6Y20cGjNpdQ7jccVOg3DOZP2vAA9RLHPsjs4IY1kJDAi83e25WkAokLBDY43_0EhBZYpHUv0ElrKrChz7PgkF7GhT-Xz0hdarNFVlz8OZJXrU9KEil8A",
"width" : 800
},
{
"height" : 485,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110354877626525435377/photos\"\u003eFranck Moulinier\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAFKpEYwIPFiRu2ccpPIfB_PmmHuiNlAnqgaGRt6mJ4FbSQdRjNW1mv3hP90Twyb2XeNEdyaYselLmrI7bu5egQeCVkvaG_IxKwgbXxL9h5lke4z0O44KStJdPk4hqsg8nNbuF5lp_Qe23MvB24r26pCS_j0_au4ftSnWIRiR_UY7EhAZSylqsZuFi_1AJlTg9fMaGhQlZn2ukuIjytpfVAPVETjRgTuTRg",
"width" : 840
},
{
"height" : 544,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110354877626525435377/photos\"\u003eFranck Moulinier\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAA9cxa3nipj_jYYzUgyVCFXGvurTnBU5IkWgcqYf1sR_Adqj7S3neoPyoVebI0G7C6hFK5m7-YOWnXZrXH9HDEsp7cX3am1SG34Rb2mg-_WzXoLs-4Z75DK060h7iusyTHz1bzSda3Tv_skJYR7QkBKVZt2wCbicUvFnSsTYccxdEhCivONHvfNPRTfnm42sh6g2GhRtkE1CV6HxACVOiu9KHR0ToRng3g",
"width" : 800
}
],
My question is simple: how can I add photos with a POST place add request on Google Places API? Place Photos seems to be read-only.
EDIT:
To be more specific, I'm calling Google Places API from my web-app in PHP.

Have a look at Google My Business API. It allows to submit photos to your locations:
https://developers.google.com/my-business/reference/rest/v3/accounts.locations#Location

Related

Google Places Autocomplete API does not bias for location

I am using the Autocomplete API to get results 'biased' for current location with the following request:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuli&types=(regions)&key=[KEY]
The API returns the following response:
{
"predictions" : [
{
"description" : "Kulim Kedah Malaysia",
...
"types" : [ "locality", "political", "geocode" ]
},
{
"description" : "Kuliyapitiya, North Western Province, Sri Lanka",
...
"types" : [ "locality", "political", "geocode" ]
},
{
"description" : "Kulithalai, Tamil Nadu, India",
...
"types" : [ "locality", "political", "geocode" ]
},
{
"description" : "Kuligów, Poland",
...
"types" : [ "locality", "political", "geocode" ]
},
{
"description" : "Kulin, Western Australia, Australia",
...
"types" : [ "locality", "political", "geocode" ]
}
],
"status" : "OK"
}
As you can see above, the response does not bias for location. The doc says that the IP Address is taken into account when returning "near" locations. But from the response, the Indian locations are not returned first over others (The request IP address is Indian).
Even, when I pass location parameter with lat,long, as:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuli&types=(regions)&location=lat,long&key=[KEY]
still the Indian results are not prioritized over other response.
How do I make the API return location 'biased' over IP address or location coordinates? Thank you for your time.
Add components to your url: &components=country:IN
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuli&components=country:IN&types=(regions)&location=lat,long&key=[KEY]

FHIR complex extension

How can I add an extension that has multiple fields ?
For example if I have a extension related to visit motives that is structured like this in my application :
"visit_motive":
{
"id": "1",
"label": "Visit motive name",
"color": "#000000",
"duration": 5
}
I have something like this for the moment :
"extension": [
{
"url": "https://api.test.com/fhir/StructureDefinition/schedule-visit_motives",
"valueIdentifier": "visit_motive1_id",
"valueString" : "visit motive name",
"valueString" : "#000",
"valueInteger" : 5,
},
{
"url": "https://api.test.com/fhir/StructureDefinition/schedule-visit_motives",
"valueIdentifier": "visit_motive2_id",
"valueString" : "visit motive name 2",
"valueString" : "#111",
"valueInteger" : 10,
}
]
But I'm pretty sure it is not correct since I can't name the fields since I have to precise value[x] each time.
How can I do it ?
You would do that with a complex extension, which is basically an extension containing extensions. You can see more information about extensions in the spec. Scroll down a bit for the complex one. Or view an example of the structure of a complex extension here.
The use of your extension would look something like this:
"extension" : [{
"url" : "https://api.test.com/fhir/StructureDefinition/schedule-visit_motives",
"extension" : [{
"url" : "id",
"valueIdentifier": "visit_motive1_id"
}, {
"url" : "label",
"valueString" : "visit motive name"
}, {
"url" : "color",
"valueString" : "#000"
}, {
"url" : "duration",
"valueInteger" : 5,
}]
}]

Google places API not returning address components

My program is trying to determine the City, state, and country based on some text, for example "New york yankee stadium" I want to get New york city, NY, USA. I am using Google places API to do this. According to the documentations, the API should return a list of address component https://developers.google.com/places/web-service/details. However, right now its only returning formatted address "1 E 161st St, Bronx, NY 10451, United States".
here is my web service url
https://maps.googleapis.com/maps/api/place/textsearch/json?key=MY_KEY&query=new%20york%20yankee%20stadium
Anyone familiar with google places API that can let me know if I am not writting the right query or parameter?
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "1 E 161st St, Bronx, NY 10451, United States",
"geometry" : {
"location" : {
"lat" : 40.82964260000001,
"lng" : -73.9261745
},
"viewport" : {
"northeast" : {
"lat" : 40.83279975,
"lng" : -73.92236575000001
},
"southwest" : {
"lat" : 40.82643674999999,
"lng" : -73.93052034999999
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "3d78036d61d35f48650bda737226432b57d82511",
"name" : "Yankee Stadium",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"photos" : [
{
"height" : 540,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101696810905045719819/photos\"\u003eYankee Stadium\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAIxmCLrNS_XZ2FcJqVvRVtBUlNYMBVTVKppOWBu7sICj2q70cqJARBoJlTcZpydbMTzURKWWMVJhYpVCqsnia5pjmDhjvjsTirrEnAc6gvmRYKuUwgewB9Re--FulXzXZ5DY3P9fkwIwuc4U9BJVbqHD5O-N6SbbHcqn4XHUj_OdEhCoNPZ3kiNJhxOCGdYG5O4DGhTqVfUjdq7JzasqYATvQxkL1-H3xg",
"width" : 1242
}
],
"place_id" : "ChIJcWnnWiz0wokRCB6aVdnDQEk",
"rating" : 4.4,
"reference" : "CmRRAAAA5dHiw1YmLxW60_jITBZjMiUs48L4aVUqlPnPDpN_ySa7rw8kPp04WWk0qf8mG-kkMFSNzh39lP0YwfynW54tLcY4s_EYbAPvNWTMe6wXHm_FJiVbI0Lfenyxz4yOTzunEhDgI64EWoXkQe9k45y6qP3-GhSVSdCMPPZA3joFbnYGV-bqo2e0lw",
"types" : [ "stadium", "point_of_interest", "establishment" ]
}
],
"status" : "OK"
}
Its a two step process, first search and get the place_id from google places search service,
use the returned place_id and pass it with another call to receive the individual address components,
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJcWnnWiz0wokRCB6aVdnDQEk&key=
{"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "1",
"short_name": "1",
"types": [
"street_number"
]
},
{
"long_name": "East 161st Street",
"short_name": "E 161st St",
"types": [
"route"
]
},
{
"long_name": "Concourse",
"short_name": "Concourse",
"types": [
"neighborhood",
"political"
]
},
{
"long_name": "Bronx",
"short_name": "Bronx",
"types": [
"sublocality_level_1",
"sublocality",
"political"
]
},
{
"long_name": "Bronx County",
"short_name": "Bronx County",
"types": [
"administrative_area_level_2",
"political"
]
},

Why "_links" returned for Single resource and "links" returned for retrieving collection via REST call

I have developed a REST API which can return a collection of Object or a Single Resource as per the Request. I have also added "self" link on each object Programmatically (Spring Hateos).
Link self = ControllerLinkBuilder.linkTo(TenantController.class).slash(tenant.getTenantId()).withSelfRel();
tenantResource.add(self);
When the response body is returned I am getting "_links" on single resource GET where as "links" on getting the collection. why is this difference ?
URL (GET) - http://localhost:8080/tenants
Response (it has "links")
========================
[
{
"tenantId": "56c98ebb42d34bd98763f61a",
"name": "ONGC India",
"abbreviation": "ONGC",
"description": "ONGC India is a Indian Organization",
"links": [
{
"rel": "self",
"href": "http://localhost:8080/tenants/56c98ebb42d34bd98763f61a"
}
]
}
]
==========================================================================
URL (GET) - http://localhost:8080/tenants/56c98ebb42d34bd98763f61a
Response (it has "_links")
==========================
{
"tenantId" : "56c98ebb42d34bd98763f61a",
"name" : "ONGC India",
"abbreviation" : "ONGC",
"description" : "ONGC India is a Indian Organization",
"_links" : {
"self" : {
"href" : "http://localhost:8080/tenants/56c98ebb42d34bd98763f61a"
}
}
}

Blender exporter - "uncaught syntaxError unexpected token" THREE.JSONLoader()

Have you come across this erro: "uncaught syntaxError unexpected token"
When loading a model exported from Blender 2.63a with the three exporter addon?
From this code copied from three.js github example
var loader = new THREE.JSONLoader();
loader.load( {"buffalo.js", function(geo){createModel(geo)}});
Thanks
Regards
Chris
Check whether the model has a material. Search in buffalo.s for the string: "material" : ,. If you find that string, your model has no material assigned - bad syntax error appears! Go to blender, assign material, and export again to buffalo.js.
Not working:
...
"objects" :
{
"Monkey" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"material" : ,
"position" : [ -0.150241, 5.41906, 2.96394 ],
"rotation" : [ 0.874236, 0.0220203, -3.11527 ],
"quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
"scale" : [ 2.9257, 2.86503, 2.68207 ],
"visible" : true,
"castShadow" : false,
"receiveShadow" : false,
"doubleSided" : false
},
...
},
...
Working:
...
"objects" :
{
"Monkey" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"material" : "Material",
"position" : [ -0.150241, 5.41906, 2.96394 ],
"rotation" : [ 0.874236, 0.0220203, -3.11527 ],
"quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
"scale" : [ 2.9257, 2.86503, 2.68207 ],
"visible" : true,
"castShadow" : false,
"receiveShadow" : false,
"doubleSided" : false
},
...
},
...
I got this working by leaving out the JSON signature of the load function. Like this:
loader = new THREE.JSONLoader();
loader.load( 'buffalo.js',function( geo )
{
....
Hope this helps
Regards

Resources