gpt4 book ai didi

javascript - 如何在 bing map 中绘制路径或线两个图钉?

转载 作者:行者123 更新时间:2023-11-30 12:51:34 24 4
gpt4 key购买 nike

您好,我想使用 Javascript SDK 在 bing map 中的两个图钉之间绘制线条或路径。这是我想要类似这样的谷歌地图示例。

google map example

最佳答案

给你,你需要有你的必应 map 凭证。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

<script type="text/javascript">

var map = null;
function GetMap() {
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Your Bing Map Credentials"});

var loc1 = new Microsoft.Maps.Location(33.719753, -117.98925);
var loc2 = new Microsoft.Maps.Location(33.993065, -117.918015);
var loc3 = new Microsoft.Maps.Location(34.13095, -118.25497);

// Add a pin to the map
var pin1 = new Microsoft.Maps.Pushpin(loc1);
var pin2 = new Microsoft.Maps.Pushpin(loc2);
var pin3 = new Microsoft.Maps.Pushpin(loc3);

// Create a polyline
var lineVertices = new Array(loc1, loc2, loc3);
var line = new Microsoft.Maps.Polyline(lineVertices);

map.setView({center:loc2, zoom: 9} );

map.entities.push(line);
map.entities.push(pin1);
map.entities.push(pin2);
map.entities.push(pin3);

}
</script>
</head>
<body onload="GetMap();">
<div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>

关于javascript - 如何在 bing map 中绘制路径或线两个图钉?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20795475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com