Android : Google Places API show icon / image of place within radar search?

on Sunday, March 22, 2015


I'm playing with the Google Places API and enjoying it but can't quite seem to get the desired results.


Ultimately what I'd like to produce is a radar search that displays items of type bar, restaurant within a 5km radius. As well as a map pointer I'd like to pull through an icon or a photo of that place.


I'm most of the way there but the many options I've tried for photo are failing. I can display a static image from my library as the icon (commented out in the code below) but I'd very much like the photo instead.


If that's not possible then I'd like to assign staticImage x to type Bar and staticimage2 to type y.


Can anyone perhaps shed some light on what I'm doing wrong please and if not possible, could you suggest an alternative approach?


Many thanks!



for (var i = 0, result; result = results[i]; i++) {

//var place = results[i].place;
var marker = new google.maps.Marker({
map: map,
position: result.geometry.location,
place : {
placeId : results[i].place_id,
location : results[i].geometry.location,
photo : results[i].photo - doesn't work
},
title: results[i].place_id + ' : ' + results[i].geometry.location - problems here as well. :(
//icon: "/assets/images/cake_32x32.png" - This works -
//icon : results[i].photos[i].getUrl({'maxWidth': 35,'maxHeight': 35}) - This doesn't
});

0 comments:

Post a Comment