Friday, 19 October 2018

openlayers - Dynamically add layer(s) to Layer Group


I have an Openlayers 3 app and users can retrieve stored routes from a web service and display them on a map. Currently each route is added to the top of the index but I'd like them to be inserted into an existing Layer Group.


I've tried using these to methods so far but to no avail:


var collection = map.getLayerGroup(plannerLayers);
collection.push(loadedRoute);

map.addLayer(loadedRoute); // this is the only method which works


map.getLayerGroup(plannerLayers).addLayer(loadedRoute);

Layer management in general is something I seem to be struggling with and ideally I'd like to just be able to interrogate the map for vector layers and add discrete functionality to them. Is there a way to programmatically add/remove layers to a group or even move between groups?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...