【发布时间】:2011-06-21 12:42:12
【问题描述】:
我正在按照http://www.gisdoctor.com/v3/mapserver.html 的代码使用 API v3 将 WMS 作为图像覆盖在 Google 地图上。上面链接的js代码如下
"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 x 256 瓦片。毫不奇怪,因为这是我要求的。但是,在http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c22837333f9a1812/d410a2a453025b38 的讨论之后,似乎我最好从地图服务器请求一个未处理的(单个)图像。这会减少我的服务器的负担。无论如何,我想尝试使用单个图像,但我无法正确构造一个请求。
具体来说,我将图块的大小更改为较大;例如,我尝试了 1024 x 1024 的瓷砖。我确实得到了较少的图块,但返回的图像与 Google 地图基础层边界不匹配。
我想要的是根本不指定图块大小。相反,我应该动态计算出图块大小比当前地图大小大 256 像素。这样,无论地图大小如何,都将返回单个图像。此外,将借助沿地图边缘的额外 256px 实现无缝平移。
建议?
【问题讨论】:
-
您找到解决方案了吗?它看到 Weather Underground 的好人使用这种方法进行映射:wunderground.com/wundermap。也许他们中的一个会看到这个并跳进去:)
标签: google-maps-api-3 wms