GithubHelp home page GithubHelp logo

style-switcher's People

Contributors

el avatar stevage avatar dsgh avatar favna avatar olivierhill avatar dependabot[bot] avatar

Stargazers

Ala Baganne avatar Anthony DeLeon avatar Martin May avatar Ryan TG avatar Alejandro Zuleta avatar Ryan Tan Rui Ann avatar Brian Moir avatar fiberOMS avatar Kaveh avatar Brendan Bohn avatar Thomas Gratier avatar Rudo Kemper avatar Daniel Sczepansky avatar  avatar Ko Nagase avatar Vedant Modi avatar Nuno Facha avatar Xlaez avatar Lukas Stuart-Fry avatar Joseph Thuha avatar Jinghao Hu avatar Henry Babbage avatar Mohammad H. Sattarian avatar Lucas Coupez avatar Emrah Burak Gürbüz avatar Myles McManus avatar _truemen avatar  avatar Chao Li avatar scabeen1 avatar Ferşat Özçelik avatar huangli avatar  avatar Florian Katerndahl avatar Alexander Semyenov avatar Johanna Fagerås avatar Julius Tens avatar Lucas Vogel avatar Rhys Stubbs avatar Hugo Barjot avatar Lorenzo Brutti avatar Ahmed Mahmoud avatar Morgan Aldridge avatar Jagad Yudha Awali avatar Diligent Marketing Solutions avatar Yigit Aksoy avatar Agent Smith avatar Brenton Morris avatar Ibrahim Mohammed avatar Marcel Siegmann avatar Emmanuel Jolaiya avatar Shane Loeffler avatar Daniel Kerkow avatar Chris Amico avatar  avatar martinadamsdev avatar José Ferrão avatar Megan Makela avatar Supryanto Widadi Putra avatar Jin Igarashi avatar A. Erdem Şentürk avatar Gilbert Wong avatar brambow avatar Yuichiro Aoki avatar Bruno Salerno avatar Chris Marx avatar Yousef Qamaz avatar Nick Doiron avatar Daniel Batchford avatar Sebastian Hancock avatar chuhuiZhuang avatar Devin Norgarb avatar Simon Norris avatar hosoya avatar  avatar  avatar 刘鹏 avatar haopf avatar Dan Majka avatar wei avatar Sajal Sharma avatar  avatar  avatar lewin avatar Al-Khawarizmi avatar Ryan Shaw avatar NG Plex avatar randomnerd avatar Anatolii Suhanov avatar Matias Iglesias avatar

Watchers

Ko Nagase avatar  avatar Jin Igarashi avatar  avatar Matias Iglesias avatar

style-switcher's Issues

support layer toggle method of switching styles

One way I sometimes implement style switching is creating a single Style in Studio comprised of layers from multiple styles concatenated together, then to switch the style it's just a matter of toggling layers on and off.

I liked the UI and scaffolding your style-switcher provided so used it as a base and made that change at master...alantgeo:toggle-layers

I took a few shortcuts when working on my fork, like removing all the TS so it's not PR ready), so this is more of a feature request, maybe it's worth supporting a few different styles of style switching, in particular this layer toggle method.

In my fork I also added a dist build using rollup which was handy for me.

Events

Hello,

ho do I intercept mouse click event on style-switcher control?

Provide a way to update active style (so the correct style is bold in the option menu)

The app I am working on includes manual updates to the base map style that happen outside of the style switcher. It would be nice if the style switcher took its active state for option bolding from the basemap in the map regardless of how it was set. Im assuming the active state for a style gets set when a user selects a style with the switcher, but maybe there can be a listener that sets the active state on basemap change instead (assuming Mapbox provides such a listener that would work)

Right now I am considering manually updating the css classes myself but that is really hacky and not durable.

Hide list when clicken selected style option

When you currently click the selected style option, the styles list won't get hidden, unlike the other options in the list. If you select one of them, the list disappears. To hide the list without selecting another style than the selected one, you need to click on the map outside of the list, which is not very user friendly in my opinion. Is it possible to change this behaviour?

Preserve existing layers when switching, or add beforeChange and onChange callback options

I found it surprising that when changing the map style, all my existing layers were blown away (I'm suprised mapbox can't do this automatically). The best I can tell, this appears to currently be the best way to preserve layers on the mapbox map when changing styles:

mapbox/mapbox-gl-js#4006 (comment)

It would be amazing if this could be implemented generically, or as a fallback, at least add change hooks so that users can cache the existing layers before a style change, and then reapply them after the style change has been made-

Use without NPM?

I've noticed that many plugins allow users to use an api.mapbox.com URL to import the plugin into an HTML file. Is this possible with style-switcher? If so, what is the URL?

No code for onRemove method

To be able to translate each title, it's mandatory to remove the control and create a new on with translated titles.
There is no code in your OnRemove method.
According to the MapBox Api documentation https://docs.mapbox.com/mapbox-gl-js/api/#icontrol
please thanks add those 2 lines :

  this.controlContainer.parentNode.removeChild(this.controlContainer);
    this._map = undefined;

Source map problem with npm 8.12.0

Getting next in terminal:

WARNING in ./node_modules/mapbox-gl-style-switcher/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Source\XXX\node_modules\mapbox-gl-style-switcher\lib\index.ts' file: Error: ENOENT: no such file or directory, open 'D:\Source\XXX\node_modules\mapbox-gl-style-switcher\lib\index.ts

Edit:
See this: react/create-react-app#11924 (comment)

Can't use spaces in layer titles

Due to this line, if you try to use a space in a layer title (eg, "Mapbox Outdoors"), you get this error:

DOMException: "String contains an invalid character"

Not really sure if there's much value adding the title as a class, but if so, I'd suggest something like this:

styleElement.classList.add(style.title.replace(/[^a-z0-9-]/gi, '_'));

Projection switching

Thank you so much for this awesome plugin!
Is it possible to create another library or implement a feature into this library, which makes it possible to switch between the different projections that were added to the mapbox-gl-js library?

Allow to choose default style

Currently, there's no way to change the default style of 'Streets'. Even if the map starts with a different style, the selector will not show the map's initial style as active, it will show Streets as active.

It would be great if either we could pass in the default style (maybe as second parameter to MapboxStyleSwitcherControl?), or if it would "read" from the map what style is there as default, and start with that.

Thoughts?

Question.. Switch styles and maintain state?

Hi, I've recently implemented a very similar component myself, before discovering this one!

The main difference being that I needed to maintain sources/layers/feature state in-between style switches. This is semi-baked into my version but I feel like this could be a useful feature for others too...

My question is whether or not you'd accept a PR for this feature?

closeModal immediately executed in shadow DOM context

Hello, i'm using the widget in a stencil component with maplibre but no list is displayed because the closeModal method is executed right after the openModal one.

I think the problem is with the shadow DOM: i noticed that if replace
document.addEventListener("click", this.onDocumentClick);

with

this.map.getContainer().addEventListener("click", this.onDocumentClick);

Then the modal is displayed correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.