I'm working with Google's Places API (http://code.google.com/apis/maps/documentation/places/). I'd like to use the icons that Google passes as part of the places result set, but they look huge and out of scale.
According to Google's docs on the Marker object, the Marker.setIcon method should auto scale the image to fit the map.
I'm using something like this:
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
marker.setIcon(place.icon);
and it works, but the image isn't scaling. It appears to be about ~75px square no matter what. I have also tried writing this image into a new MarkerImage object which I could then scale, but this seems pretty over complicated.
Is there a trick to getting the icon image to scale properly?
Ok I didn't get any ideas here, so I went ahead and created a new MarkerImage object and scaled that. Works fine, not quite elegant, but here it is:
// pass in the place object returned by the Google Place API query
function createPlace(place){
var gpmarker = new google.maps.MarkerImage(place.icon, null, null, null, new google.maps.Size(25, 25));
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location,
title: place.name,
icon: gpmarker
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With