Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Enabling/disabling sources on demand. (Enhancement request). #818

Closed
mb12 opened this issue Feb 5, 2015 · 6 comments
Closed

Enabling/disabling sources on demand. (Enhancement request). #818

mb12 opened this issue Feb 5, 2015 · 6 comments
Labels

Comments

@mb12
Copy link

mb12 commented Feb 5, 2015

At the moment the only way to enable/disable sources is to change the style.json file. It would be useful to be able to do so programmatically via an API exposed through objective C wrapper.

@kkaefer kkaefer added the feature label Feb 5, 2015
@ljbade
Copy link
Contributor

ljbade commented Feb 6, 2015

When you mean "enable/disable sources" what are you referring to?

You can currently enable/disable style classes and load different style.json files.

@mb12
Copy link
Author

mb12 commented Feb 6, 2015

I experimented with getAppliedStyleClasses with bright style to figure out what it is. But it always returns an array with 0 objects.

I've included below specific uses cases.

1.) The style.json file has 3 different sources. These need to be enabled conditionally. When a source is enabled/disabled any layer referring to that source in style.json should get enabled/disabled.

The only way I have been able to figure out to do this is to create a new style.json and apply it.

2.) For a layer with specific "id" in style.json file, I need to do things like the following:
- Change fill opacity dynamically for certain layers.
- disable layers with certain "ids". By disable I mean all Buckets created for that style "id" are not rendered/deleted.

@ljbade
Copy link
Contributor

ljbade commented Feb 7, 2015

So why are enabling disabling sources? What exactly are you trying to do?

The reason you get 0 length array is because bright does not have any classes in its style json.

Try it with outdoors and you will get night and day styles.

@mb12
Copy link
Author

mb12 commented Feb 8, 2015

Thank you very much for the response.
I believe I can use classes for my second use case. For the first case, I actually need to have the Source removed from Map::activeSources set. Enable/disable "classes" still keeps the "Source" under "activeSources" i.e. it continues to be rendered and tiles fetched for that source.

Use case #1:
I have "two" vector sources that are rendered over a base map. The base map can be changed dynamically to any of the following:

  • A low scale base map bundled in the application.
  • Regular vector street map
  • Satellite imagery.

Of the two vector source rendered on the basemap, at least one will be active at any time.
I would like to disable a source specified in style.json in the sense that it gets removed from "Map::activeSources" set.

Dynamically generated style.json approach is cumbersome for modeling this (Also due to the start/stop bug, unreliable at the moment). Ideally I would like to have a static style.json and enable/disable Sources dynamically.

Use case # 2:
A use case for dynamically changing opacity attribute for a layer within a source is the following. I believe this is something I could do with classes.

  • When base map is satellite, I need to logically make certain area layers transparent. This is similar to overlaying only street names and POIs on satellite imagery.

@ljbade
Copy link
Contributor

ljbade commented Feb 8, 2015

Thanks for the info I now see what you are trying to do.

I wonder if we can make the logic smarter to prevent loading sources not referenced in the current class.

Thoughts @jfirebaugh?

@jfirebaugh
Copy link
Contributor

This is part of #837.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants