通过在 ASP.NET 网站中指定地址来显示 Bing 地图

发布于 2024-09-27 10:23:28 字数 71 浏览 1 评论 0原文

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

How to display Bing map dynamically in an ASP.NET website based on the address provided. I do not have latitude and longitude for the address so I have to pass address directly and display the map.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木森分化 2024-10-04 10:23:28

在 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);
  }
}

In the ASP.Net mark up page, I have a hidden field which contains address. Based on this address, bing map gets loaded using the script mentioned below. A pushpin is placed on the address for easy identification of the address.

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);
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文