Problem using GIcon () for google maps

When I do not use GIcon (), the location point is displayed correctly. However, when I use GIcon (), the location is displayed in the wrong place. Here is my code:

<script language="javascript">
  var Icon = new GIcon();
  Icon.image = "images/myicon.png";
  Icon.iconSize = new GSize(10, 10);
  Icon.iconAnchor = new GPoint(5, 34);
  Icon.infoWindowAnchor = new GPoint(5, 2);
  var markers = [{'latitude': 169.132892, 'longitude': -44.698667, 'name': 'dsfsdfljsldk' }]; var map;
  var centerLatitude = 18.17;
  var centerLongitude = 127.57;
  var startZoom = 2;
</script>
+3
source share
1 answer

The size of your icon is 10x10 pixels, but you set it to 10x34 pixels from the upper left corner of the icon .

You probably want your icon to be tied to a map with a 10x10 icon size. If you want the anchor to be in the center of the icon, set the icon to the icon (5.5).

+3
source

Source: https://habr.com/ru/post/1709073/


All Articles