Skip to main content
typo
Source Link
jgrocha
  • 5.5k
  • 26
  • 46

Check the documentation: Although this source receives tiles with vector features from the server, it is not meant for feature editing.

So, you can not add a ol.interaction.Draw interaction to add features directly to your ol.source.VectorTile. That is waywhy you get the error this.source_.addFeature is not a function.

Use a ol.layer.Vector with a GeoJSON source.

    var vectorSource = new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        loader: function (sourceExtent, resolution, projection) {
            (...)
            var features = (new ol.format.GeoJSON()).readFeatures(result.data);
            vectorSource.addFeatures(features);
            (...)
        }
    });

    var vectorJSON = new ol.layer.Vector({
        source: vectorSource 
    });

Check the documentation: Although this source receives tiles with vector features from the server, it is not meant for feature editing.

So, you can not add a ol.interaction.Draw interaction to add features directly to your ol.source.VectorTile. That is way you get the error this.source_.addFeature is not a function.

Use a ol.layer.Vector with a GeoJSON source.

    var vectorSource = new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        loader: function (sourceExtent, resolution, projection) {
            (...)
            var features = (new ol.format.GeoJSON()).readFeatures(result.data);
            vectorSource.addFeatures(features);
            (...)
        }
    });

    var vectorJSON = new ol.layer.Vector({
        source: vectorSource 
    });

Check the documentation: Although this source receives tiles with vector features from the server, it is not meant for feature editing.

So, you can not add a ol.interaction.Draw interaction to add features directly to your ol.source.VectorTile. That is why you get the error this.source_.addFeature is not a function.

Use a ol.layer.Vector with a GeoJSON source.

    var vectorSource = new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        loader: function (sourceExtent, resolution, projection) {
            (...)
            var features = (new ol.format.GeoJSON()).readFeatures(result.data);
            vectorSource.addFeatures(features);
            (...)
        }
    });

    var vectorJSON = new ol.layer.Vector({
        source: vectorSource 
    });
Source Link
jgrocha
  • 5.5k
  • 26
  • 46

Check the documentation: Although this source receives tiles with vector features from the server, it is not meant for feature editing.

So, you can not add a ol.interaction.Draw interaction to add features directly to your ol.source.VectorTile. That is way you get the error this.source_.addFeature is not a function.

Use a ol.layer.Vector with a GeoJSON source.

    var vectorSource = new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        loader: function (sourceExtent, resolution, projection) {
            (...)
            var features = (new ol.format.GeoJSON()).readFeatures(result.data);
            vectorSource.addFeatures(features);
            (...)
        }
    });

    var vectorJSON = new ol.layer.Vector({
        source: vectorSource 
    });