2

Is ServerVector broken in OpenLayers 3.5?

Just running the following gives an error:

var wfsTest = new ol.source.ServerVector({
    format: new ol.format.GeoJSON()
});

The error is: "Object doesn't support this action"

Am I doing something wrong?? It used to work fine in previous OpenLayers 3.x versions.

2 Answers 2

6

According to the change log of 3.5.0:

The ol.source.ServerVector class has been removed. If you used it, for example as follows:

var source = new ol.source.ServerVector({
    format: new ol.format.GeoJSON(),
    loader: function(extent, resolution, projection) {
        var url = …;
        $.ajax(url).then(function(response) {
            source.addFeatures(source.readFeatures(response));
        });
    },
    strategy: ol.loadingstrategy.bbox,
    projection: 'EPSG:3857'
});

you will need to change your code to:

var source = new ol.source.Vector({
    loader: function(extent, resolution, projection) {
        var url = …;
        $.ajax(url).then(function(response) {
            var format = new ol.format.GeoJSON();
            var features = format.readFeatures(response,
            {featureProjection: projection});
            source.addFeatures(features);
        });
    },
    strategy: ol.loadingstrategy.bbox
});
0
0

This is still helping in 2020. Going through an OL 3 tutorial and to help me understand better I'm trying to also do them in OL 6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.