查看使用 javascript API 的 this 示例。
基本上,您可以将自定义图标的锚点坐标定义为标记的中心。不要使用中间,而是使用卡车图标的底部尖端/边缘。查看“iconAnchor”属性:
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34); // THIS IS WHAT YOU CARE ABOUT
baseIcon.infoWindowAnchor = new GPoint(9, 2);
在您的情况下,您可以将锚值设置为:
// Assuming the tip is exactly in the middle at the bottom of the icon
.iconAnchor = new GPoint(iconWidth/2, 0);
我没有使用您提到的 gwt-maps - 但由于它们总是包装 javascript API,您应该能够找到要设置的等效属性。你能链接到你正在使用的 gwt-maps 实现吗?