How to align the icon of a marker in google map

google-maps, google-maps-markers, javascript

Solution

What You need is to create a `MarkerImage` object, for example:

var markerImage = new google.maps.MarkerImage('img/icons/bank_euro.png',
                new google.maps.Size(30, 30),
                new google.maps.Point(0, 0),
                new google.maps.Point(15, 15));

Where first parameter is an image url, second is image size, third is origin point of image, and fourth is position on the image where marker should point. If your marker is a circle then set fourth parameter to center of the image. And create your marker passing `markerImage` to icon property:

var marker = new google.maps.Marker({
  map: map,
  position: placeLoc,
  icon: markerImage
});

Problem

In google map usually the center bottom of the image of the marker is the lat lng of a point that it has to mark. Imagine my marker icon is a circle, I would like the center of it to be at the lat-lng of the given point... Code: ``` var image_hotspot = 'img/icons/bank_euro.png'; var marker = new google.maps.Marker({ map: map, position: placeLoc, icon: image_hotspot }); ```

Original source