[OpenLayers-Users] How to merge TMS and WMS correctly with
openlayers?
Myeong Hun Jeong
mhjeong74 at gmail.com
Wed Sep 10 05:07:13 EDT 2008
Dear list.First, I made tiled images(png) with gdal2tiles.py.
For example, python gdal2tiles.py -title "tile" -publishurl
http://192.168.1.134:8089/osgeo/geo/tile/ -nogooglemaps -nokml -v
D:\test\raster\image.tif D:\test\raster\tile --config GDAL_CACHEMAX 120
and I moved the image files into Tomcat and tested
http://localhost:8089/osgeo/geo/tile/openlayers.html.
It runs well.
Next, I want to add a WMS layer which are being serviced in Geoserver &
Postgis.
So, I changed javascript.
function init(){
OpenLayers.DOTS_PER_INCH = 90.714;
var bounds = new OpenLayers.Bounds(
199628.88671875, 396702.2890625,
239834.30078125, 431934.58125
);
var options = {
controls: [],
maxExtent: bounds,
maxScale: 10,
minScale: 500000,
maxResolution: "auto",
projection: "EPSG:4326",
units: 'm'
};
map = new OpenLayers.Map('map', options);
//WMS base layer
var base_wms = new OpenLayers.Layer.WMS(
"topp:bml_gadm_as_w - Untiled",
"http://localhost:8888/geoserver/wms",
{layers: 'topp:bml_gadm_as_w'},
{singleTile: true, ratio: 1}
);
map.addLayer(base_wms);
// OpenLayers 2.5 TMS driver
var layer = new OpenLayers.Layer.TMS( "TMS",
"http://192.168.1.134:8089/osgeo/geo/tile/",
{layername: '.', serviceVersion: '.', type:'png'} );
map.addLayer(layer);
//WMS river layer
var river_wms = new OpenLayers.Layer.WMS(
"topp:bml_rivr_as_w - Untiled",
"http://localhost:8888/geoserver/wms",
{
layers: "topp:bml_rivr_as_w",
transparent: "true", format: "image/png"},
{singleTile: true, ratio: 1,minScale:"100000"}
);
map.addLayer(river_wms);
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element:
$('location')}));
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
But, the problem is that tiled images do not match WMS layer. The tiled
images are aerial photos of the same area.
I don't understand exactly the projection. is this projection problem?
Could you give some advice.
Best regards.
Jeong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080910/882bd41a/attachment.html
More information about the Users
mailing list