[OpenLayers-Dev] ol3 - projection issues

Tim-Hinnerk Heuer th.heuer at gmail.com
Thu May 2 16:51:04 PDT 2013


Hi,

I'm wanting to include our WMS-V project into (at least) my development
version of ol3.  However, I have a couple of issues.  The main one is that
I cannot get our WMS to display.  Apparently, it is using the wrong EPSG
code (as verified by looking at the requests), even though I defined it
similarly to the custom projection example.

We are using EPSG:2193 which is the projection of our data and is not
trivial to change.

The relevant portion in the HTML is:

<script src="http://ourenvironment.scinfo.org.nz/js/OpenLayers/proj4js.js"
type="text/javascript"></script>
    <script src="
http://ourenvironment.scinfo.org.nz/js/OpenLayers/defs/EPSG2193.js"
type="text/javascript"></script>
    <script src="loader.js?id=wms-v" type="text/javascript"></script>

I have the following code in my example:

goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.layer.ImageLayer');
goog.require('ol.projection');
goog.require('ol.source.SingleImageWMS');
goog.require('ol.source.TiledWMS');

var layers = [
  new ol.layer.TileLayer({
    source: new ol.source.TiledWMS({
      url: 'http://maps.scinfo.org.nz/basemaps/wms?',
      params: {
          'LAYERS': 'landscape_eco_painted_relief',
          'TILED': true,
          'VERSION': '1.1.1'
      },
      extent: [1000000, 4700000.0000001, 2200000, 6300000]
    })
  })
];
var projection = ol.projection.configureProj4jsProjection({
  code: 'EPSG:2193',
  extent: [1000000, 4700000.0000001, 2200000, 6300000],
  units: 'm'
});
var map = new ol.Map({
  //renderer: ol.RendererHint.CANVAS,
  renderer: ol.RendererHint.DOM,
  projection: projection,
  layers: layers,
  target: 'map',
  view: new ol.View2D({
    center: [1600000, 5500000],
    zoom: 4
  })
});

However, it doesn't work as expected.  The requests are going to for
example:
http://maps.scinfo.org.nz/basemaps/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&LAYERS=landscape_eco_painted_relief&TILED=true&STYLES=&SRS=EPSG%3A3857&BBOX=2504688.542848654%2C5009377.085697312%2C5009377.08569731%2C7514065.628545968
which is obviously the wrong projection.

Note: When I zoom out a lot, I can see a faint hint of New Zealand, so it
seems like it could work.

Any help would be much appreciated.

Regards,
Tim

Tim-Hinnerk Heuer

Twitter: @geekdenz
Blog: http://www.thheuer.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20130503/c688df25/attachment.html>


More information about the Dev mailing list