Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps API: Marker image positioning

I have changed the image that I use for a marker on Google maps. The new image is much wider than the old one and I have noticed that the marker is aligned with the lat and lng so that the marker rests with it's horizontal midpoint over the lat and lng. This is not what I want, I want to have the lat and lng aligned with the markers left hand side - I want to offset the marker from the default position by about 80px to the right.

like image 909
David Avatar asked Mar 15 '11 22:03

David


1 Answers

Try this on for size.

var markerImage = new google.maps.MarkerImage('/img/icon/here.png',
    new google.maps.Size(80, 80), //size
    new google.maps.Point(0, 0), //origin point
    new google.maps.Point(0, 80)); // offset point
marker[stamp] = new google.maps.Marker({
    position: loc, // loc is a variable with my lngLat object
    title: params.name,
    map: window.gMaps[params.map],
    icon: markerImage
});
like image 108
Brian Noah Avatar answered Nov 09 '22 06:11

Brian Noah