Skip to main content
6 events
when toggle format what by license comment
Mar 17, 2015 at 23:32 vote accept kosataka
Mar 16, 2015 at 19:26 comment added Stacy Bowler In theory you might be able to use a variable because most things are just object references, but it's hard to say if there might be some other issues. I'd suggest just calling the setSource function on the layer when you are ready to set the source or want to change it.
Mar 16, 2015 at 18:39 comment added kosataka So, I've set up four layers and have them working with visiblity changes. How would I go about changing the source on the layer? That sounds EXACTLY like what I want to do! If I set the source path of the layer to a variable, can I change the variable when I click on the image preview?
Mar 16, 2015 at 15:59 comment added Stacy Bowler It depends a lot on your use case, but OL3 is quite dynamic to do different things. If you find a large number of layers being an issue, you could add a group to the map and dynamically add and remove layers from it. Another option would be to change the source on a layer as needed. Or something that I've done is not load or set the source on a layer until a certain time later when needed for instance if you have a large source that takes a while to load and you don't want to bog down the page on load time.
Mar 15, 2015 at 6:46 comment added kosataka Does this mean that every layer you add initially will be part of the load time for the map? This would be ideal if you could set it to load some arbitrary number of layers, say 4, set 1 to visible and 3 to invisible (to be toggled later), but not load say another 4 layers until needed. I like what you suggested, as long as the load time doesn't skyrocket and the map doesn't reach its maximum layer limit over time (perhaps a function that removes old layers completely above a certain number). That means you have to have a way to add the layer back if the user wants to though... ideas? Thanks !
Mar 11, 2015 at 19:21 history answered Stacy Bowler CC BY-SA 3.0