以下代码在 bing 地图上绘制了一条简单的线。有没有办法让这条线的起点和终点在最近的道路上。我不想使用路由服务。如果加载时间与下面的代码一样快,那就太好了。
谢谢你。
<!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.49753, -117.54845);
var loc2 = new Microsoft.Maps.Location(33.993065, -117.87415);
// Add a pin to the map
var pin1 = new Microsoft.Maps.Pushpin(loc1);
var pin2 = new Microsoft.Maps.Pushpin(loc2);
// Create a polyline
var lineVertices = new Array(loc1, loc2);
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);
}
</script>
</head>
<body onload="GetMap();">
<div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>