I am working on a small JavaScript application for displaying map with WMS layers from 2 servers. The problem is, that image is stretched by latitude, it is wider, than it should be.
This is is how it is working now: http://postimg.org/image/pxk8lfnnd/
and this is how it should be, and how it Google maps displaying: http://postimg.org/image/al321lg6l/
This is JavaScript code:
var map = new OpenLayers.Map("map");
var ol_wms = new OpenLayers.Layer.WMS(
"NP Podyjí WMS",
"http://mapy.nppodyji.cz/cgi-bin/mapserv.exe?map=f:/mapserv/projects/map/nppodyji_wms.map",
{
layers: "nppodyji_wms,hranice_npt,hranice_np,cyklo_CR",
transparent: "true",
format: "image/png"
},
{ isBaseLayer: false, visibility: true }
);
var ol_cz = new OpenLayers.Layer.WMS(
"Česká republika",
"http://geoportal.gov.cz/ArcGIS/services/CENIA/cenia_arccr/MapServer/WMSServer",
{layers: "0,3,4,6,7,10,12,13,14,15,16,17,19,20,21,22,23,24"}
);
map.addLayers([ol_cz, ol_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
setTimeout(function() {
var fromProjection = new OpenLayers.Projection("EPSG:102067"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var position = new OpenLayers.LonLat(15.8186 + (15.9626 - 15.8186) / 2,48.8027 + (48.8866 - 48.8027) / 2 ).transform( fromProjection, toProjection);
map.setCenter(position, 13);
}, 100);
I tried many map.projection and map.displayProjection changes, but I'm not really sure, if it's projection problem.
It is only an example of bigger application, which take points from database and displays them dynamicaly. Displaying is correct; problem is, that client don't want it in different shape
Projection should be EPSG:102067, in HTML I have also included proj4js.js.
EDIT: I've solved only half of the problem: Without any display settings, it is displayed like this: http://postimg.org/image/czs81gzwj/ When I used:
var ol_cz = new OpenLayers.Layer.WMS(
"Czech",
"http://geoportal.gov.cz/ArcGIS/services/CENIA/cenia_t_podklad/MapServer/WMSServer",
{layers: "blablabla"},
{ projection: new OpenLayers.Projection('EPSG:3857')}
);
it looks like this: http://postimg.org/image/vm8rkxgoz/ so exactly what I want! However problem is with another WMS server. When I was trying to change projection, or displayProjection in:
var ol_wms = new OpenLayers.Layer.WMS(
"NP Podyji WMS",
"http://mapy.nppodyji.cz/cgi-bin/mapserv.exe?map=f:/mapserv/projects/map/nppodyji_wms.map",
{
layers: "nppodyji_wms,hranice_npt,hranice_np,cyklo_CR",
transparent: "true",
format: "image/png"
},
{ isBaseLayer: false, visibility: true } ,
{ projection: new OpenLayers.Projection('EPSG:XXX'),
displayProjection: new OpenLayers.Projection("EPSG:XXX")
}
);
It has basically no effect :/. I was trying several projections in "projection" attribute, also in displayProjection, but only visible output was http://postimg.org/image/yv0oe22tf/ (note the pink square on the bottom). So it get some parameters, but they are wrong, or maybe he server is wrong, I'm not really sure.
The 2nd WMS did not fit in the baselayer (1st WMS)