0

In my Openlayers 3.9.0, I use Bing Maps and OSM layers. They both are EPSG 3857.

var layer = new ol.layer.Tile({
        source: new ol.source.OSM({})
    });

    var bingMapsAerial = new ol.layer.Tile({
        source: new ol.source.BingMaps({
            key: '////',
            imagerySet:'AerialWithLabels'
        })
    }); 

I set the extent that the layers mast fit in

var textent = ol.proj.transformExtent([2297128.5, 4618333, 2459120.25, 4763120], 'EPSG:900913', 'EPSG:3857'); 

I also set a layer from PostGIS

    var ait = new ol.layer.Tile({
    extent: textent,
    source: new ol.source.TileWMS({
      url: 'http://localhost:8080/geoserver/mymap/wms?',      
       params: {'LAYERS': 'mymap:polygon, mymap:line', 'TILED': true,  'VERSION': '1.3.0','FORMAT': 'image/png' ,'CRS': 'EPSG:3857'},
       serverType: 'geoserver'
     })
   })

My view is

var view = new ol.View({
    center: center,
    extent : textent,
    zoom: 6,
    maxZoom:20
});

and my map

var map = new ol.Map({
    target: 'map',
    layers:[bingMapsAerial, layer, ait],
    view: view
});

map.getView().fit(textent, map.getSize()); 

The raster tile layer is in EPSG 900913 in PostGIS and Geoserver says EPSG:900913 as Native SRS and Declared SRS. Both polygon and line layers that compose the tile layer have slightly different Native Bounding Box and Lat/Lon Bounding Box, but they render the same spatial region. Both polygon and line layers have Published zoom levels and Cached zoom levels set to 0 -20 in Geoserver to match the Openlayers View settings

Aren't EPSG 900913 and EPSG 3857 supposed to be the same?

Both Bing and OSM layers look ok, but the tile layer appears smaller than the other two.

How do I proceed? Am I missing something, a setting or var? Is there a hack? Do I have to convert the PostGIS data?

  • What's the purpose of ol.proj.transformExtent? That return value should be the same as the input. – Mintx Oct 8 '15 at 21:22
  • @Mintx I am trying to convert the Bounting Box from its original EPSG 900913 to EPSG 3857 that the layers have. Sorry I dont actually get you – slevin Oct 8 '15 at 21:52
  • As you mentioned in the question, EPSG 900913 and EPSG 3857 are identical, so the bounding box values shouldn't change. If they do change, then there's something wrong with ol.proj.transformExtent. – Mintx Oct 8 '15 at 21:54
  • @Mintx If I go here and transform from 900913 to 3857 the coords are identical. The new problem is when I try to do var textent = ol.extent[2297128.5, 4618333, 2459120.25, 4763120]; layers fit, but the map is not zoomed in correctly to the defined area and I get Uncaught AssertionError: Assertion failed: invalid extent or geometry from OpenLayers. Any tips? – slevin Oct 9 '15 at 15:06
1

I have found that mis-aligned WMS layers are often due to differences between the cache and client config.

GeoWebCache, the cache server integrated with GeoServer, will silently accept a 10% diff between the closest cached resolution and the requested resolution.

I would disable caching entirely on your local tile server to see if it fixes your issue. If it does, you have confirmed that it is a cache issue and can investigate it further.

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.