[OpenLayers-Users] Cannot read property 'yx' of undefined

Dylan Parry dylan.parry at bluefoxtech.co.uk
Fri Oct 18 05:06:15 PDT 2013


Hi,


I’m trying to use a WMS with the EPSG:27700 projection. The WMS uses version 1.3.0, which is causing a few problems. I have got to a point where I cannot figure out what’s wrong.


I am currently getting the following error:


Cannot read property ‘yx’ of undefined


and having read up a little, it appears that it’s due to the WMS version wanting to know whether to reverse the coordinates or not for the bbox parameter, but as the projection is unknown to OpenLayers there’s no yx property to query.


My problem is that I have no idea where to add that property to.


Here’s the code I have so far:


<script src="~/Scripts/proj4js.js"></script>
<script>
    Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs";
</script>
<script src="/Scripts/openlayers/openlayers.js"></script>
<script>
    var map, opus;


    function init() {
        OpenLayers.ImgPath = "/Scripts/openlayers/img/";


        var options = {
            maxExtent: new OpenLayers.Bounds(0, 0, 700000, 1300000),
            restrictedExtent: new OpenLayers.Bounds(0, 0, 700000, 1300000),
            projection: new OpenLayers.Projection('EPSG:27700'),
            units: 'm',
            scales: [10000, 25000, 50000, 75000, 100000, 150000, 175000, 200000],
            controls: [
                new OpenLayers.Control.Navigation({ 'zoomWheelEnabled': false }),
                new OpenLayers.Control.MousePosition(),
                new OpenLayers.Control.PanZoomBar(),
                new OpenLayers.Control.LayerSwitcher()
            ]
        };


        map = new OpenLayers.Map('map', options);


        opus = new OpenLayers.Layer.WMS(
            'OpenStreetMap via Opus',
            'http://server/wms',
            {
                layers: 'OpenStreetMap',
                version: '1.3.0',
                crs: 'EPSG:27700',
                format: 'image/png',
            },
            {
                isBaseLayer: true,
                transitionEffect: 'resize'
            }
        );
        map.addLayer(opus);


        map.zoomToMaxExtent();
        map.zoomToScale(10000, true);
        map.setCenter(new OpenLayers.LonLat(195775, 223755));
    }
</script>


I also have an onload event that calls the init() function to draw the map on the page.


Any idea how to fix the error I’m getting? I’ve tried adding an xy property to the WMS bit of the code where ‘isBaseLayer’ is defined, but that didn’t seem to work.


Thanks,


-- 
Dylan Parry

Blue Fox Technology Ltd
Tel: 01492 532100
Web: http://www.bluefoxtech.co.uk

Registered in England and Wales, Company No. 0508226.
Registered office: Windsor House, 26 Mostyn Avenue, Craig-Y-Don,
Llandudno, Conwy LL30 1YY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20131018/4f6590fd/attachment.html>


More information about the Users mailing list