0

The vector data displays, but its down near null island, I have been trying this for a couple hours now and nothing I try has worked. Can you see why this code refuses to place the data on the right location?

Source is data EPSG:27700 var proj is EPSG:3857 I have swapped dataProjection & featureProjection which has zero effect.

var vectorSource = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    loader: function(extent, resolution, projection) {
        var proj = projection.getCode();
        console.log(proj);
        var url = "site.com?typeName=my:layer=WFS&version=1.0.0&request=GetFeature&outputFormat=application%2Fjson&bbox=" + extent.join() + ",EPSG:3857"
        var xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        var onError = function() {
            vectorSource.removeLoadedExtent(extent);
        }
        xhr.onerror = onError;
        xhr.onload = function() {
            if (xhr.status == 200) {
                vectorSource.addFeatures(
                    vectorSource.getFormat().readFeatures(xhr.responseText,{
                        dataProjection: 'EPSG:27700',
                        featureProjection: 'EPSG:3857'
                    }));
            } else {
                onError();
            }
        }
        xhr.send();
    },
    strategy: ol.loadingstrategy.bbox
});
2
  • Have you defined the EPSG:27700 projection in your code?
    – JGH
    Apr 19, 2018 at 14:29
  • Yeah I have. The data in question displays fine if I display using a TileWms as the source, but I would like to use the snap-to functionality for this layer - hence the vector.
    – Ryan
    Apr 19, 2018 at 14:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.