Search code examples
javascriptopenlayersprojectionproj4jsmapnik

How can I use a Mapnik-Backgroundlayer with lat-lon layers in one map with OpenLayers?


I have an application with a map-client using OpenLayers. I want to use Mapnik-data as background-layer, as provided with the class OpenLayers.Layer.OSM.Mapnik. For that I have to switch to the projection EPSG:900913. But I also want to display some layers, that I can only request in EPSG:4326. Can I combine both layers with the different projections in one map with OpenLayers and how can I do that?


Solution

  • If your layers are vector (WFS, KML, GeoRSS etc.) then you can reproject them with OpenLayers in the browser.

    http://docs.openlayers.org/library/spherical_mercator.html#working-with-projected-coordinates

    If your layers are raster (images / WMS services etc.) then they cannot be reprojected:

    http://docs.openlayers.org/library/spherical_mercator.html#creating-spherical-mercator-raster-images

    You'd have to do this via the WMS service itself (through MapServer / ArcGIS / GeoServer).