Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Dynamically add data to geoJSONShape #341

Open
@v1r0x

Description

@v1r0x

I'm very happy with ui-leaflet, but now I'm stuck. I had all my geojson data in an object which looked like this:

map.map.geojson = {
    data: {
        type: 'FeatureCollection',
        features: []
    },
    style: {...},
    onEachFeature: {...}
}

The data gets loaded in the background and is then pushed to map.map.geojson.data.features.
The map.map.geojson is passed to the leaflet directive <leaflet geojson="map.geojson"></leaflet>.
Now I want to split the data into different geojson layers. Therefore I get a list with different element groups which are my different layers. I set up these layers as so:

for(var i=0; i<list.length; i++) {
    var elem = list[i];
    var currentLayer = {};
    currentLayer.name = elem.name;
    currentLayer.type = 'geoJSONShape';
    currentLayer.data = {
        type: 'FeatureCollection',
        features: []
    }
    currentLayer.layerOptions = {
        style: {...},
        onEachFeature: {...}
    }
    ...
    map.map.layers.overlays[elem.id] = currentLayer;
}

But I don't see anything on my map. onEachFeature doesn't get called. I couldn't find any tutorial or code on how to update a layer of type geoJSONShape. Is this even possible? Did I miss something?

regards
v1r0x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions