mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Add vector layer with itself style url after load map with main style

Open AryaNyx opened this issue 7 years ago • 3 comments

Hi We are using mapbox on android. we have our own style and everything is ok except that adding a vector source with it's specific style out of main loaded style. It means that after map loaded with our main style , we need to add a vector layer with it's source and style over the main style dynamically ( i.e by clicking a button ). We didn't find any helpful feature in documentation and in search results.

Steps to reproduce

  1. Load Main Style
  2. Add Vector Layer with its source and style with separate endpoints 3.

Expected behavior

We expect that mapbox style should have a feature that we can add vector source with it's own style that is separate than main loaded style. both vector source and it's style with different endpoint url. We are using like this :

loadedStyle.addSource(VectorSource("metro", "https://ourwebsite:metro@EPSG:900913@pbf/{z}/{x}/{y}.pbf"))

but it needs an style to show this source that we should write it's expression by hard code it. for example in future when we want change it's layer color we should update app to change the expression , but if it support to load it's style from url we can change it's style whenever we want.

Actual behavior

Configuration

**Android versions: 8.0.0 **Device models: xiaomi mi mix **Mapbox SDK versions: 7.3.2 ( latest till this post )

AryaNyx avatar May 13 '19 10:05 AryaNyx

@AliKhoshraftar

We expect that mapbox style should have a feature that we can add vector source with it's own style that is separate than main loaded style. both vector source and it's style with different endpoint url.

I believe that you have a bit of misconception what a style is. A style object is a combination of Sources (the data) and Layers (the visual representation). As you already noticed, you can add a VectorSource and you are also able to add layers at runtime using Style#addLayer.

tobrun avatar May 14 '19 13:05 tobrun

Hey , thank you for your response. The problem is i can't addLayer with url, we need add vector source with its layer from url not build it in app.

AryaNyx avatar May 15 '19 05:05 AryaNyx

Layers can't be loaded form a url, the closest thing relevant to this would be to add a layer based on json data as requested in https://github.com/mapbox/mapbox-gl-native/issues/13467

tobrun avatar May 15 '19 08:05 tobrun