【问题标题】:How to bound tile layers in Bing Maps AJAX Control, Version 7.0如何在 Bing Maps AJAX Control 7.0 版中绑定切片图层
【发布时间】:2012-05-22 04:37:08
【问题描述】:

我一直在尝试将 Weather Central 中的图块叠加到 Bing 地图上,但遇到了问题。我可以调用一个图块并将其推到地图上,但是,无论图块有多大,它都会将图块放在地图上的任何地方。我希望能够将其绑定到特定位置,但无法弄清楚 7.0 中的方式。在 6.3 中,规范似乎很简单:http://msdn.microsoft.com/en-us/library/bb429629.aspx,但在 7.0 中则不然。他们在这里有一个例子:http://www.bingmapsportal.com/isdk/ajaxv7#TileLayers1,但即使使用他们的代码,它仍然会将瓷砖放在任何地方。

到目前为止,这是我的代码: 函数GetMap() {

          map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), { credentials: "my creds" });
          var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: 
          'http://datacloud.wxc.com/?type=tile&datatype=forecast&var=Temperature&time=now&bing=023212&vs=0.9&passkey=my_passkey', height: 256, width: 256});
          var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: .7 });

           // Push the tile layer to the map
           map.entities.push(tilelayer);

}

我在哪里执行函数 GetMap() onload。

谢谢

【问题讨论】:

    标签: javascript ajax bing-maps


    【解决方案1】:

    看起来您在请求中硬编码了一个特定的平铺四键 (023212) - 您需要将其替换为 {quadkey} 占位符,以便为每个位置请求适当的平铺图像。即:

    map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), { credentials: "my creds" });
    var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: 
      'http://datacloud.wxc.com/?type=tile&datatype=forecast&var=Temperature&time=now&bing={quadkey}&vs=0.9&passkey=my_passkey', height: 256, width: 256});
    var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: .7 });
    
    // Push the tile layer to the map
    map.entities.push(tilelayer);
    

    (未经测试,因为我没有访问相关服务的密钥)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多