[OpenLayers-Dev] ol3 - projection issues

Andreas Hocevar ahocevar at opengeo.org
Mon May 6 07:52:42 PDT 2013


You forgot to specify the projection in the View2D settings. See
http://ol3js.org/en/master/examples/wms-custom-proj.html for a working
example.

Also note that OL3 questions should be asked at
https://groups.google.com/d/forum/ol3-dev.

Andreas.

On Fri, May 3, 2013 at 1:51 AM, Tim-Hinnerk Heuer <th.heuer at gmail.com> wrote:
> 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
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Dev mailing list