Google maps 将自定义图层添加到谷歌地图

Google maps 将自定义图层添加到谷歌地图,google-maps,Google Maps,我正在尝试为温度/雷达/湿度应用WeatherBug提供的自定义层。使用谷歌javascript库将etc导入我的谷歌地图 我需要在我的谷歌地图上应用透明瓷砖 我从下面的url中获得了平铺图像。那么我怎样才能把它绑定到我的地图上呢 您应该能够将其添加为Google自定义地图类型。基本上,在请求WeatherBug API时,您会得到一个可以在Google地图上使用的互动程序 你可以从谷歌地图上找到这些文档 您要开始的代码可能如下所示,您可以从这一点着手: var tileLayerOverlay

我正在尝试为温度/雷达/湿度应用
WeatherBug
提供的自定义层。使用谷歌javascript库将etc导入我的谷歌地图

我需要在我的谷歌地图上应用透明瓷砖

我从下面的url中获得了平铺图像。那么我怎样才能把它绑定到我的地图上呢


您应该能够将其添加为Google自定义地图类型。基本上,在请求WeatherBug API时,您会得到一个可以在Google地图上使用的互动程序

你可以从谷歌地图上找到这些文档

您要开始的代码可能如下所示,您可以从这一点着手:

var tileLayerOverlay = new GTileLayerOverlay(
  new GTileLayer(null, null, null, {
    tileUrlTemplate: 'http://i.wxbug.net/GEO/Google/Temperature/GetTile_v2.aspx?as=0&c=0&fq=0&tx={X}&ty={Y}&zm={Z}&mw=1&ds=0&stl=0&api_key=xxxxx',
    isPng:true,
    opacity:1.0
  })
);

map.addOverlay(tlo); 

另外,请查看和其中的链接。

以下是WMS服务的解决方案,由以下人员提供:

您只需根据需要调整函数即可

function MCustomTileLayer(map,url) {
this.map = map;
this.tiles = Array();
this.baseurl = url;
this.tileSize = new google.maps.Size(256,256);
this.maxZoom = 19;
this.minZoom = 3;
this.name = 'Custom Layer';
this.visible = true;
this.initialized = false;
this.self = this;
}

MCustomTileLayer.prototype.getTile = function(p, z, ownerDocument) {
for (var n = 0; n < this.tiles.length ; n++) {
    if (this.tiles[n].id == 't_' + p.x + '_' + p.y + '_' + z) {
        return this.tiles[n];
    }
}
var tile = ownerDocument.createElement('IMG');
tile.id = 't_' + p.x + '_' + p.y + '_' + z;
tile.style.width = this.tileSize.width + 'px';
tile.style.height = this.tileSize.height + 'px';
tile.src = this.getTileUrl(p,z);
if (!this.visible) {
    tile.style.display = 'none';
}
this.tiles.push(tile);

while (this.tiles.length > 100) {
    var removed = this.tiles.shift();
    removed = null;
}
return tile;
};

MCustomTileLayer.prototype.getTileUrl = function(p,z) {
var url = this.baseurl +
          "&REQUEST=GetMap" +
          "&SERVICE=WMS" +
          "&VERSION=1.1.1" +
          "&BGCOLOR=0xFFFFFF" +
          "&TRANSPARENT=TRUE" +
          "&SRS=EPSG:3857" +
          "&WIDTH=256" +
          "&HEIGHT=256" +
          "&FORMAT=image/png" +
          "&mode=tile" +
          "&tilemode=gmap" +
          "&tile="+ p.x + "+" + p.y + "+" + z
return url;
}
和删除覆盖

map.overlayMapTypes.setAt(0,null);

谢谢你,尼拉夫。。但是我正在尝试从WeatherBug提供者添加一个层。我们可以使用提供程序提供的url从此提供程序检索平铺层。所以你能帮我做这个吗..我如何获取我放大的当前磁贴,以便将参数传递给WeatherBug url?TileLayer通常自己做-请参见
tileUrlTemplate
中的{X}、{Y}和{Z}参数。
map.overlayMapTypes.setAt(0,null);