【问题标题】:Display Bing map by specifying an address in an ASP.NET website通过在 ASP.NET 网站中指定地址来显示 Bing 地图
【发布时间】:2010-10-12 11:46:36
【问题描述】:

如何根据提供的地址在 ASP.NET 网站中动态显示 Bing 地图。我没有地址的经纬度,所以我必须直接传递地址并显示地图。

【问题讨论】:

    标签: asp.net bing-maps bing-api


    【解决方案1】:

    在 ASP.Net 标记页面中,我有一个包含地址的隐藏字段。基于此地址,使用下面提到的脚本加载 bing 地图。地址上放置了一个图钉,方便识别地址。

    var map = null;
    var pinid = 0;
    
    function GetMap() {
    
        map = new VEMap('theMap');
         map.LoadMap();
        map.SetZoomLevel(10);
        FindLoc(); 
    }
    
    function FindLoc() {
        try {
            map.Find("<b>Property Address:</b>",
                                document.getElementById('ctl00_head_HiddenField1').value,
                                  null,
                                  null,
                                  1,
                                  1,
                                  true,
                                  true,
                                  true,
                                  true,
                                  ProcessResults);
        }
        catch (e) {
            alert(e.message);
        }
    }
    
    function ProcessResults(layer, results, places, hasmore)
    {
      CreatePin("Default", places[0].LatLong);
    }
    
    function CreatePin(type, point)
    {
      if (point != 'Unavailable')
      {
          var pin = new VEShape(VEShapeType.Pushpin, point);
          pin.SetTitle('<b>Property Address:</b>');      
          pin.SetDescription(document.getElementById('ctl00_head_HiddenField1').value);
          map.AddShape(pin);
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-02
      • 2011-09-09
      • 1970-01-01
      • 2012-10-09
      相关资源
      最近更新 更多