Google Maps marker alignment issues during zooming when using a svg marker -
for reason, when zooming in , out svg marker that's defined using path, marker isn't aligned correctly it's position. evident in one of google's examples.
interestingly, if use 1 of built in svg symbols, not appear problem.
i using svg path marker , suffers alignment issues:
m 256,480c-84.828,0-153.6-68.157-153.6-152.228c0-84.081, 153.6-359.782, 153.6-359.782s 153.6,275.702, 153.6,359.782c 409.6,411.843, 340.828,480, 256,480z m 255.498,282.245c-26.184,0-47.401,21.043-47.401,46.981c0,25.958, 21.217,46.991, 47.401,46.991c 26.204,0, 47.421-21.033, 47.421-46.991 c 302.92,303.288, 281.702,282.245, 255.498,282.245z
what cause of problem?
edit: mrupsidown solving problem. svg needs have anchor point @ (0,0) of canvas.
see image (i using illustrator, other svg editing app should do):
updated fiddle here: http://jsfiddle.net/tf83z/
you have define anchor point of svg marker.
see documentation: https://developers.google.com/maps/documentation/javascript/reference#icon
anchor: position @ anchor image in correspondance location of marker on map. default, anchor located along center point of bottom of image.
it can tricky find right point among values of path when using symetric symbol , if want anchor on path edge.
var icon = { path: "m 256,480c-84.828,0-153.6-68.157-153.6-152.228c0-84.081, 153.6-359.782, 153.6-359.782s 153.6,275.702, 153.6,359.782c 409.6,411.843, 340.828,480, 256,480z m 255.498,282.245c-26.184,0-47.401,21.043-47.401,46.981c0,25.958, 21.217,46.991, 47.401,46.991c 26.204,0, 47.421-21.033, 47.421-46.991 c 302.92,303.288, 281.702,282.245, 255.498,282.245z", fillcolor: '#ffff00', fillopacity: .6, anchor: new google.maps.point(255.498,-26.204), strokeweight: 0, scale: .25, rotation: 180 }
i have added default marker reference.
Comments
Post a Comment