我遵循代碼http://www.gisdoctor.com/v3/mapserver.html將WMS作爲圖像疊加在使用API v3的Google地圖上。在上面的鏈接JS代碼如下所示WMS作爲谷歌地圖v3中的單個平鋪圖像
"WMSGetTileUrl" : function(tile, zoom) {
var projection = map.getProjection();
var zpow = Math.pow(2, zoom);
var ul = new google.maps.Point(
tile.x * 256.0/zpow,
(tile.y + 1) * 256.0/zpow
);
var lr = new google.maps.Point(
(tile.x + 1) * 256.0/zpow,
tile.y * 256.0/zpow
);
var ulw = projection.fromPointToLatLng(ul);
var lrw = projection.fromPointToLatLng(lr);
var bbox = ulw.lng() + "," + ulw.lat() + "," + lrw.lng() + "," + lrw.lat();
return url = "http://url/to/mapserver?" +
"version=1.1.1&" +
"request=GetMap&" +
"Styles=default&" +
"SRS=EPSG:4326&" +
"Layers=wmsLayers&" +
"BBOX=" + bbox + "&" +
"width=256&" +
"height=256&" +
"format=image/png&" +
"TRANSPARENT=TRUE";
},
"addWmsLayer" : function() {
/*
Creating the WMS layer options. This code creates the Google
imagemaptype options for each wms layer. In the options the function
that calls the individual wms layer is set
*/
var wmsOptions = {
alt: "MapServer Layers",
getTileUrl: WMSGetTileUrl,
isPng: false,
maxZoom: 17,
minZoom: 1,
name: "MapServer Layer",
tileSize: new google.maps.Size(256, 256)
};
/*
Creating the object to create the ImageMapType that will call the WMS
Layer Options.
*/
wmsMapType = new google.maps.ImageMapType(wmsOptions);
map.overlayMapTypes.insertAt(0, wmsMapType);
},
一切工作正常,但是,當然,WMS返回爲256×256的瓷磚。沒有驚喜,因爲這就是我所要求的。然而,在http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c22837333f9a1812/d410a2a453025b38的討論之後,似乎我可能會更好地向mapserver請求一個untiled(單個)映像。這會減少我的服務器。無論如何,我想嘗試一個單一的圖像,但我無法正確構建一個請求。
具體來說,我把瓷磚的大小改成了很大的東西;例如,我嘗試了1024 x 1024的圖塊。我確實獲得了較少的圖塊,但返回的圖像與Google Maps基本圖層邊界不匹配。
我想是根本不指定瓷磚大小。相反,我應該動態地確定圖塊的大小,例如比當前地圖大小大256個像素。這樣,無論地圖大小如何,都會返回單個圖像。此外,無縫平底鍋將在地圖邊緣附加256px的幫助下實施。
對此提出建議?
您是否曾經找到過解決方案?它看到Weather Underground的好人們使用這種方法進行映射:http://www.wunderground.com/wundermap/。也許其中一個會看到這個並跳進:) – malonso