javascript 如何在 Bing 地图 v7 上创建自定义图钉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6123895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to create a custom pin on Bing maps v7
提问by James Radford
Can someone show me how to custom the pin for Bing maps, version 7.0 please? I'm experimenting with upgrading from version 6 which has a custom icon but I cant find anywhere that shows how to do this with version 7. I have the following code so far.
有人可以告诉我如何自定义 Bing 地图 7.0 版的图钉吗?我正在尝试从具有自定义图标的版本 6 升级,但我找不到任何显示如何使用版本 7 执行此操作的地方。到目前为止,我有以下代码。
Many thanks,
非常感谢,
var map = null;
var pinInfobox = null;
function GetMap()
{
map = new Microsoft.Maps.Map(document.getElementById("myMap"), {
credentials: "xxx",
height: 236,
width: 269,
enableClickableLogo: false,
enableSearchLogo: false,
mapTypeId: Microsoft.Maps.MapTypeId.road,
showDashboard: false});
var loc = new Microsoft.Maps.Location(47.592, -122.332);
var pin = new Microsoft.Maps.Pushpin(loc);
map.entities.push(pin);
map.setView({ center: loc, zoom: 6 });
}
回答by Gingemonster
check out the reference documentation which has an "icon" option to set a custom icon
查看参考文档,其中有一个“图标”选项来设置自定义图标
回答by Paul Mendoza
There is a really good site that documents how to do this exact operation.
有一个非常好的网站记录了如何执行此确切操作。
http://www.bingmapsportal.com/isdk/ajaxv7#Pushpins2
http://www.bingmapsportal.com/isdk/ajaxv7#Pushpins2
Here is the JavaScript from that site that says how to do it:
这是该站点的 JavaScript,说明了如何操作:
map.entities.clear();
var pushpinOptions = {icon: virtualPath + '/Content/SpaceNeedle.jpg', width: 30, height: 50};
var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), pushpinOptions);
map.entities.push(pushpin);