2012-05-21 35 views
0

我一直在試圖將來自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但即使使用他們的代碼,它仍然會把瓷磚放到任何地方。如何綁定Bing地圖AJAX控件7.0版中的圖塊圖層

這是到目前爲止我的代碼: 功能的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。

感謝

回答

0

它看起來就像你在硬編碼您的要求特定瓷磚quadkey(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); 

(未經測試,因爲我沒有一個密鑰來訪問相關服務)