**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
4天前关闭。
Improve this question
我希望在我的谷歌MapAPI中添加自定义标记。我希望使用JavaScript、HTML和CSS在大头针的中心放置一个徽标。我已经添加了一个参考,说明我希望大头针如何显示在下面。对于如何执行此操作,有任何建议或帮助吗?目前,我的标记代码如下所示,但是,我不喜欢别针本身的外观,我无法将本Map像添加到别针的中心。
- 更新-
我已经创建了一个我想使用的大头针的图像,但是它显示的比我喜欢的要大。我如何减小我的标记大头针的大小?
// Add another marker to the map
var marker1 = new google.maps.Marker({
position: {lat: 40.79816525932935, lng: -73.96851680216488},
map: map,
icon: 'assets/img/columbiapin.png',
});
我试着用下面的代码替换代码,这是应该正确缩放的代码,但相反,标记消失了。
// Add another marker to the map
var marker1 = new google.maps.Marker({
position: {lat: 40.79816525932935, lng: -73.96851680216488},
map: map,
icon: {
url: 'assets/img/columbiapin.png',
size: new google.maps.Size(40, 40),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(20, 40)
}
});
1条答案
按热度按时间3qpi33ja1#
谷歌Map提供了一种创建自定义Map的方法,其中还包括一种添加自定义图标的方法。但是,图标不会被放置在标记内。我发现解决方案是创建一个您想要的别针的图像,然后将其包含在您的代码中。我将包含代码,然后我用来编辑我的图像的大小和比例