I have a map with OSM as a base layers and several layers on top of that. Two layers (red polygons with gray fill and black placemarks) are instances of TileLayer (source TileWMS -> geoserver). Both layers are stored in postgis database and published on geoserver.

If I set map projection 'EPSG:4326' than placemarks are displayed correctly (as it looks when looking at png representing placemark). Image below:

enter image description here

EPSG:4326 doesn't fit my needs as it distorts northern parts of map. That's why I tried to change to EPSG:3857.

enter image description here

And I understand that polygons are squeezed because of projection change. However, is there possibility to prevent placemarks from being squeezed/streched after change of projection.

  • 3
    If the marker icons can only be served as EPSG:4326 raster there is no way to avoid distortion when reprojecting (which isn't a problem for true polygons like the river valleys). Is there any way the marker layer can be served as EPSG:3857 raster or as vectors? – Mike Feb 26 at 13:55
  • Marker icons are currently served as raster WMS layer (layer consists of set of points) . So if I would like to have markers to look the same in any projection I would have to publish these points as vector layer (e.g. via WFS) and then style them within openlayers? – Saša Vranić Feb 26 at 14:01
  • EPSG:3857 is distorting the data north-south instead of 4326's east-west distortion. Maybe try EPSG:3034 (Europe Lambert conformal conic) or 3035 (Lambert azimuthal equal area) instead. – mkennedy Feb 26 at 18:35

If i understand correctly, you provide your placemarks as a WMS Layer, just like the map itself. In this case, i fear there is no possibility to prevent this distortion. Just like the labels in your map get un-distorted, your markers will get distorted, since basically they are just pictures.

Possible solutions are creating a WMS-Layer in the correct target coordinate system, or, more commonly, serve your markers as vector features and render them as markers in openlayers (no matter the projection).

  • However, I think you might be wrong. I'm not sure what is the solution but Mapstore seems to display well markers even though projection is 3857 (and data 4326). – Saša Vranić Feb 26 at 14:37

After a lot of research I found solution. So I've set projection of the view into 3857 but didn't set projection attribute of TileWMS source object. If it is not set then Openlayers is getting the layer in native projection (in this case 4326) and then reprojects the tiles which geoserver generated.

After I've set projection attribute of TileWMS object then, Openlayers is making request in 3857 projection, so Geoserver prepares the tiles in 3857 projection and placemarks are showed correctly. Plus, it is a bit faster since OpenLayers doesn't have to do heavy lifting to reproject tiles into map projection.

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.