如何在必应地图中绘制路径或画线两个图钉? [英] how to draw path or line two pushpins in bing map?

查看:111
本文介绍了如何在必应地图中绘制路径或画线两个图钉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Javascript SDK在bing地图中的两个图钉之间画线或路径. 这是我想要类似的google map示例.

Hi I want draw line or paths between two pushpins in bing map using Javascript SDK. This is a google map example I want similar like this.

推荐答案

在这里,您需要拥有必应地图凭据.

Here you go, you need to have your bing map credentials.

<!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>

这篇关于如何在必应地图中绘制路径或画线两个图钉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆