Voici une solution pour les services WMS inpired par: http://code.google.com/p/biodiversity-imageserver/source/browse/trunk/unittest/gmap3/MCustomTileLayer.js?r=49
Vous pouvez simplement ajust la fonction de vos besoins.
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;
}
Vous pouvez l'utiliser comme ça
var hMap = new MCustomTileLayer(map, "http://my_base_url");
map.overlayMapTypes.insertAt(0, hMap);
Et pour supprimer la superposition
map.overlayMapTypes.setAt(0,null);
https://developers.google.com/maps/documentation/javascript/v2/overlays –
http://lookmywebpage.com/api/google/google-map-custom-overlay-using-javascript-api-v3/ –
Merci Nirav .. Mais j'essaie d'ajouter une couche du fournisseur WeatherBug. Nous pouvons récupérer la couche de tuiles de ce fournisseur en utilisant une URL qu'ils fournissent. Alors pouvez-vous s'il vous plaît m'aider à faire cela .. – Ravish