【发布时间】:2014-06-29 04:02:32
【问题描述】:
我有一个带有几种不同类型图标的 Google 地图。我在每个图标上都有一个阴影。如何调整标记阴影与标记的偏移量?
在构建每个标记的循环中,我有:
var icon = customIcons[type];
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
图标按类型设置。
var customIcons = {
Football: {
icon: 'http://path-to-image1.png',
shadow: 'http://path-to-shadow-image1.png'
},
Lacrosse: {
icon: 'http://path-to-image2.png',
shadow: 'http://path-to-shadow-image2.png'
}
};
在这个tutorial 中,他们将单个图标的大小和偏移设置如下:
var image = new google.maps.MarkerImage('images/beachflag.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(20, 32),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32));
var shadow = new google.maps.MarkerImage('images/beachflag_shadow.png',
// The shadow image is larger in the horizontal dimension
// while the position and offset are the same as for the main image.
new google.maps.Size(37, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
在我的情况下,我有多个图标,它们被设置在一个对象中。如何将大小和偏移量添加到 var customIcons ?
谢谢。
【问题讨论】:
-
您能否提供一个 jsfiddle 中的示例或发布更多代码以便我们重现它?
标签: javascript google-maps google-maps-markers