1

我目前设法将OpenStreetMap集成到 Google Maps API 中,如本示例中所述。我想知道我是否也可以将 Bing 地图图块集成到 Google 地图 API 中。可能吗?我找不到任何相关信息。

注意:我确实知道地图绘制,但现在,我想坚持使用 Google Maps API。

提前致谢。

4

2 回答 2

7

Based on the OpenStreetMap example that you cited, I would say that it's possible but it could be quite a challenge. I would strongly advise against it since the OSM example uses version 2 of the Google API and it now officially deprecated.

But if you want to give it a try I would adapt the OSM example to point to the Bing tiles and make sure that the tileUrlTemplate property matches Bing's format for storing tiles. Unfortunately, Bing uses a quad tree format while Google uses a coordinate based format for storing tiles and accessing them via a URL. It will be important to understand the differences if you're going to make the example work so be sure to dig into the documentation links above. Also, MapTiler has a fantastic visualization of the different tile formats out there. I've found this invaluable.

Personally, I would use OpenLayers. Since Bing and Google both use spherical mercator, adding multiple tile sources to a single map is a trivial exercise. Here is an example.

于 2010-06-24T21:33:52.340 回答
2
function TileToQuadKey ( x, y, zoom){ 
  var quad = "";
  for (var i = zoom; i > 0; i--) {
    var mask = 1 << (i - 1); 
    var cell = 0; 
    if ((x & mask) != 0) cell++; 
    if ((y & mask) != 0) cell += 2; 
    quad += cell; 
  }
  return quad; 
}

var bingMapType = new google.maps.ImageMapType({
  name: "Bing",
  getTileUrl: function(coord, zoom) {
    // this returns aerial photography
    return "http://ecn.t1.tiles.virtualearth.net/tiles/a" +
      TileToQuadKey(coord.x, coord.y,  zoom) + ".jpeg?g=1173&n=z";
      // i dont know what g=1173 means
  },
  tileSize: new google.maps.Size(256, 256),
  maxZoom: 21
});
于 2013-02-26T14:38:30.750 回答