none
请教关于必应地图的SDK问题。 RRS feed

  • 问题

  • 最近在看必应地图。根据中国版SDK的实例添加不上标注。源码如下:

    只要将其中的“http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3”替换为http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.2.标注就显示不出来。不知道各位是如何使用的。还望不吝赐教。

    <!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=6.3"></script>

          <script type="text/javascript">
              var map = null;

              var LA = new VELatLong(39.9031, 116.4036);

              var pinPoint = null;
              var pinPixel = null;

              function GetMap() {
                  map = new VEMap('myMap');
                  map.LoadMap(LA, 12, VEMapStyle.Road, false, VEMapMode.Mode2D, false, 1);

                  var myPolygon = new VEShape(VEShapeType.Pushpin, LA);
                  map.AddShape(myPolygon);
                  myPolygon.SetTitle("My Polygon");
                  myPolygon.SetDescription("This is the description for my polygon.");

              }

              function getInfo() {
                  var info;

                  if (map.IsBirdseyeAvailable()) {
                      var be = map.GetBirdseyeScene();

                      info = "ID: " + be.GetID() + "\n";
                      info += "orientation: " + be.GetOrientation() + "\n";
                      info += "height: " + be.GetHeight() + "\n";
                      info += "width: " + be.GetWidth() + "\n";

                      var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

                      info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

                      // Check to see if the current birdseye view contains the pushpin pixel point.
                      info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " +
                            be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";

                      // Check to see if the current view contains the pushpin LatLong.
                      info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";

                      // This method may return null, depending on the selected view and map style.
                      info += "latlong: " + map.PixelToLatLong(pixel);

                      alert(info);
                  }
                  else {
                      var center = map.GetCenter();

                      info = "Zoom level:\t" + map.GetZoomLevel() + "\n";
                      info += "Latitude:\t" + center.Latitude + "\n";
                      info += "Longitude:\t" + center.Longitude;

                      alert(info);
                  }
              }

          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:800px; height:600px;"></div>
           <input id="btnGetInfo" type="button" value="Get Scene Information" name="getinfo" onclick="getInfo();">
           <br/>
            (zoom out 5 clicks to get latitude/longitude and zoom level)
       </body>
    </html>


    您的Money,我的动力
    2011年3月4日 0:44

答案

全部回复

  • 你是说鼠标放上去显示提示信息吗?我测试了下是可以的
    【孟子E章】
    2011年3月6日 1:28
    版主
  • 您会不会没有替换其中的SDK到中国版?全球版是正常的。但是全球版的SDK出来的都是英文的地图。请您尝试一下以下代码。地图能够正常显示,主要是出不来图钉标注。

    <!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://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.2"></script>

          <script type="text/javascript">
              var map = null;

              var LA = new VELatLong(39.9031, 116.4036);

              var pinPoint = null;
              var pinPixel = null;

              function GetMap() {
                  map = new VEMap('myMap');
                  map.LoadMap(LA, 12, VEMapStyle.Road, false, VEMapMode.Mode2D, false, 1);

                  var myPolygon = new VEShape(VEShapeType.Pushpin, LA);
                  map.AddShape(myPolygon);
                  myPolygon.SetTitle("My Polygon");
                  myPolygon.SetDescription("This is the description for my polygon.");

              }

              function getInfo() {
                  var info;

                  if (map.IsBirdseyeAvailable()) {
                      var be = map.GetBirdseyeScene();

                      info = "ID: " + be.GetID() + "\n";
                      info += "orientation: " + be.GetOrientation() + "\n";
                      info += "height: " + be.GetHeight() + "\n";
                      info += "width: " + be.GetWidth() + "\n";

                      var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

                      info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

                      // Check to see if the current birdseye view contains the pushpin pixel point.
                      info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " +
                            be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";

                      // Check to see if the current view contains the pushpin LatLong.
                      info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";

                      // This method may return null, depending on the selected view and map style.
                      info += "latlong: " + map.PixelToLatLong(pixel);

                      alert(info);
                  }
                  else {
                      var center = map.GetCenter();

                      info = "Zoom level:\t" + map.GetZoomLevel() + "\n";
                      info += "Latitude:\t" + center.Latitude + "\n";
                      info += "Longitude:\t" + center.Longitude;

                      alert(info);
                  }
              }

          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:800px; height:600px;"></div>
           <input id="btnGetInfo" type="button" value="Get Scene Information" name="getinfo" onclick="getInfo();">
           <br/>
            (zoom out 5 clicks to get latitude/longitude and zoom level)
       </body>
    </html>


    您的Money,我的动力
    2011年3月7日 0:56
  • 您好,我在IE8、firefox3.6以及safari5下测试都能出现图钉。
    2011年3月7日 14:03
    版主
  • 问题已经解决。我用的是IE 9.0.8080.16413测试确实出不来图钉。但是Safari5测试成功。由衷感谢二位给予的帮助。希望IE9,或者必应地图中国版能够给力啊。顺带一提,IE9查看全球版的正常。查看必应地图官网也正常。似乎是中国版6.2API同IE9有兼容性问题。


    您的Money,我的动力
    2011年3月9日 4:55