When I load an image into the icon property of a marker it displays with its original size, which is a lot bigger than it should be.
I want to resize to the standard to a smaller size. What is the best way to do this?
Code:
function addMyPos(latitude,longitude){
position = new google.maps.LatLng(latitude,longitude)
marker = new google.maps.Marker({
position: position,
map: map,
icon: "../res/sit_marron.png"
});
}
As mentionned in comments, this is the updated solution in favor of Icon object with documentation.
Use Icon object
If the original size is 100 x 100 and you want to scale it to 50 x 50, use scaledSize instead of Size.
MarkerImage has been deprecated for Icon
Phillippe's code would now be:
So I just had this same issue, but a little different. I already had the icon as an object as Philippe Boissonneault suggests, but I was using an SVG image.
What solved it for me was:
Switch from an SVG image to a PNG and following Catherine Nyo on having an image that is double the size of what you will use.
A complete beginner like myself to the topic may find it harder to implement one of these answers than, if within your control, to resize the image yourself with an online editor or a photo editor like Photoshop.
A 500x500 image will appear larger on the map than a 50x50 image.
No programming required.
Delete origin and anchor will be more regular picture