I'm beginning with GeoServer and try to display a map of my country (Belgium) as an OpenLayers map (embedded into a MapPanel object). I've downloaded the municipalities limits from gadm.org and copied the file into a PostGIS database (using the tools provided in the GeoServer package). I guess it is a projection issue, but I don't get why since everything is in EPSG:4326.

Here is my code:

panel = new GeoExt.MapPanel({
   title: "MapPanel",
   renderTo: "map-id",
   layers: [
        new OpenLayers.Layer.WMS("Administrative borders",
            {layers: "bel_adm4", projection:"EPSG:4326", format: "image/png"},
            {transitionEffect:'resize', isBaseLayer:true}
        maxExtent: new OpenLayers.Bounds(2.5412,49.5100,6.4013,51.502)

Here's a screenshot of the generated map:

enter image description here

Here's how Belgium should be: enter image description here

  • It's worth checking what epsg code is set up for the layer in GeoServer. As it's a wms layer OpenLayers is not going to reproject the images created on the server when it displays them on the client. – pecoanddeco May 14 '13 at 12:28
  • 4
    That's normal and correct. If you want Belgium to be less distorted, you have to use a different projection than 4326 but - as far as I know - OpenLayers only supports reprojection between 4326 and Web Mercator by default. Web Mercator might already look less distorted. – underdark May 14 '13 at 13:52

A map served by Geoserver as EPSG:4326 and displayed in OpenLayers with this "projection" will look distorted. The units of measure in a EPSG:4326 is degrees, so what you are looking at are an unprojected map.

You'll want to make Geoserver reproject your WMS to eiter EPSG:900913 (or whatever EPSG-code "web/spherical mercator" has nowdays) or a local system that covers Belgium (WGS84 UTM Zone 32N perhaps?)

Geoserver does reprojection on the fly, and supports a wide range of projections, so I would suggest trying to change your layer definition to

   new OpenLayers.Layer.WMS("Administrative borders",
            {layers: "bel_adm4", projection:"EPSG:900913", format: "image/png"},
            {transitionEffect:'resize', isBaseLayer:true}

(sidenote: While libraries like Leaflet and Google Maps makes things easy for developers by letting the user deal with coordinates that are exclusively EPSG:4326, OpenLayers does not. The projection-param set in the layer definition is sent as-is to geoserver)

| improve this answer | |
  • A tad late to mention it here, but anyhow: EPSG:31370 is the one commonly used for belgium (Lambert1972 - Conical) – Tim Couwelier Aug 22 '16 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.