如何在必应地图 AJAX 控件版本 7.0 中绑定切片图层



我一直试图将天气中心的磁贴叠加到必应地图上,但遇到了问题。我可以调用一个瓷砖并将其推到地图上,但是,无论瓷砖有多大,它都会将瓷砖放在地图上的任何位置。我希望能够将其绑定到特定位置,但无法弄清楚在 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。

谢谢

看起来您正在对请求中的特定磁贴四键 (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);

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

最新更新