Skip to content

Support "nested" styles #4000

Closed
Closed

Description

@lucaswoj

migrated from mapbox/DEPRECATED-mapbox-gl#25 by @lucaswoj

...

Users don't expect setStyle to overwrite everything, and consider the current behavior a bug. This is a bummer, and something that we could document around, saying "setStyle will wipe out the current state of the map". I'm fine with the documentation approach, but it needs a workaround, because "switching the map style" is a common usecase that is a hard expectation - it's easy to do in Leaflet and all similar tile-based libraries. -- @tmcw, 2016

Injecting custom layers into Mapbox core styles is a common use case and confusing to our users, especially when the user wants to swap out the core style and keep the custom layers.

Have we considered supporting "nested styles"? These would help our users build a solid mental model of their stylesheet, encapsulate core style implementation details, allow new kinds of style modularity, and fit nicely into Studio.

map.setStyle({
    version: 9,
    layers: [{
        type: 'style',
        layout: { url: 'mapbox://styles/mapbox/streets-v9-bottom' }
    }, ..., {
        type: 'style',
        layout: { url: 'mapbox://styles/mapbox/streets-v9-top' }
    }]
});

Activity

  1. added
    cross-platform 📺
    on Jan 17, 2017
  2. mb12 commented on Jan 18, 2017

    @mb12

    An alternative option would be to add a separate API to add points, lines and polygons. These could be internally persisted by GL JS automatically via an implicit source. GL native already supports this for feature parity with Mapkit.

  3. jaapster commented on Sep 8, 2017

    @jaapster

    @lucaswoj Could these style-layers be added dynamically? That would be very helpful.

    In our product we have a base "meta-layer", typically something like "streets-v9", containing multiple "mapbox layers" and on top of that we load our own dynamically generated "meta-layers" (containing tile sources and "mapbox layers") and GeoJSON layers for rendering of selection, drawing etc.

    This combined with inline base64 encoded icons would be awesome ...

  4. miguelleitevieira commented on Jan 24, 2018

    @miguelleitevieira

    Hi all, exist some developments on this feature?

  5. santinogue commented on Jan 29, 2018

    @santinogue

    Hi, any updates on this???

  6. stevage commented on Jul 12, 2019

    @stevage
    Contributor

    Is this essentially a duplicate of #4225?

  7. kkaefer commented on Mar 8, 2024

    @kkaefer
    Member

    We support style imports now.

  8. JamesChevalier commented on Mar 8, 2024

    @JamesChevalier

    Your link goes to an internal repository. Is this the feature you’re referring to?
    https://docs.mapbox.com/style-spec/reference/imports/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-platform 📺feature 🍏

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions