Page 1 of 1

Map JSON image response to mobile image. Automatically Create Service won't work.

Posted: Wed Mar 19, 2014 4:39 pm
by Matt6607699

How do I map a JSON response that is only an image(Google Place Photo response). The Automatically Create Service Response won't work because the only thing contained in the response is an image.

I tried to run this event after the Google Photo service completion(data/Events):

Appery("place_photo").attr("src","data");

This just loads an empty image with a torn file icon in the top right.

Is there a Service Response Parameter that I can add in order to make mapping work or can this only be done with JS? Image Image

Thank you for your Help!


Map JSON image response to mobile image. Automatically Create Service won't work.

Posted: Wed Mar 19, 2014 6:57 pm
by Maryna Brodina

Hello!

1) Mapping doesn't work because it's not json in response.
2) service complete works, but there is no data variable. Entire response is in jqXHR.responseText. But you can't put this response into image src.
3) What is this service? If it does GET request, maybe it's better to use just request URL (perhaps with parameters) as image src.


Map JSON image response to mobile image. Automatically Create Service won't work.

Posted: Thu Mar 20, 2014 5:51 pm
by Matt6607699

Thank you for the response. Ok that makes sense as to why its not working with mapping.
Your suggestion of using the request URL as the image source work perfectly! Thanks!

For anyone else that needs to get a photo from Google Places API- Google Photo service to a mobileImage, here is the code snippet:
code
Appery("MOBILE_IMAGE_NAME_HERE").attr("src","https://maps.googleapis.com/maps/api/place/photo?maxwidth=100&photoreference=CnRnAAAA5ISeGTUjAdsc0-68qiI5-NNrhhLgI6DljozNHIVaTWqPDoxwwrRph-u5-sf1qR23kyd_zS_K2BeI0nujZcSYUPmpFzo-D0E40RUS2teRtuENoqa_5VvWdayLBk64lSgtct1seXx4sqXA_-BkkpBgwhIQkcVZ1cvtECw6ncRlwrFE-hoUMef1aRpRKdPOWAOhUfvp5KRU2iE&sensor=false&key=ENTERYOURKEYHERE");
/code
photoreference is a response parameter from a google places API search. Send a second request with this photoreference to Google Photo.

Thank you for your help Maryna!