My WMS layer(EPSG:3847) looks fine in GeoServer However, it is distorted in browser: I found someone hade the same problem(Openlayers and Geoserver: OSM/Google Maps and WMS Overlay)but I still couldn't solve the problem. I also tried to add code like
var geographic = new OpenLayers.Projection("EPSG:3847");
var mercator = new OpenLayers.Projection("EPSG:4326");
var lund_center = new OpenLayers.LonLat(13.2, 55.7).transform(
geographic, mercator
and
map.setCente(lund_center, 10);
but the WMS layer is still distorted. I also tried this code but nothing's changed (EPSG3847 is not included in proj4.js, is that why the code didn't work?):
EPSG4326 = new OpenLayers.Projection("EPSG:4326");
EPSG3847 = new OpenLayers.Projection("EPSG:3847 ");
var option = {
projection: new OpenLayers.Projection("EPSG:3847 "),
displayProjection: new OpenLayers.Projection("EPSG:4326")
};
How can I solve this problem? Any help please? *the code I'm trying now are as follows, still,nothing changed:
var lon = 12.1;
var lat = 48.4;
var zoom = 10;
var map, vectors, controls;
var options = {
controls: [],
projection: new OpenLayers.Projection('EPSG:3857'),
displayProjection: new OpenLayers.Projection('EPSG:4326'),
maxExtent: new OpenLayers.Bounds(
-20037508, -20037508,20037508, 20037508.34),
//modify parameter
maxResolution: 5000,
//modify parameter
//setting zoom levels
numZoomLevels:15,
units: 'm',
};
function init(){
var map = new OpenLayers.Map({
div: "map",
allOverlays: true
});
var roads_wms = new OpenLayers.Layer.WMS( "Roads",
"http://localhost:8090/geoserver/wms/wsNYCRoad", {
projection: map.displayProjection,
layers: 'vagar_alla',
styles: '',
srs:'EPSG:3006',
transparent:true,
tiled: 'false',
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: false,
reproject: true
});
Proj4js.defs["EPSG:3006"] = "+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
var src = new OpenLayers.Projection('EPSG:3006');
var dst = new OpenLayers.Projection('EPSG:4326');
Proj4js.transform(src, dst, roads_wms);
roads_wms.projection=dst;