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.

5

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
});

Your Answer

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

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