visgl / react-map-gl

React friendly API wrapper around MapboxGL JS
http://visgl.github.io/react-map-gl/
Other
7.88k stars 1.35k forks source link

Example Interaction: Add URL hash #2308

Open tordans opened 1 year ago

tordans commented 1 year ago

This make the current zoom visible in https://visgl.github.io/react-map-gl/examples/interaction and with it understanding the options that one can set easier.

matburnham commented 12 months ago

Is this trying to add the map's position to its page's location hash? I can't seem to get the same to work with react-map-gl@7.1.6.

According to https://github.com/visgl/react-map-gl/issues/665 this was previously done with mapOptions={{ hash: true }}. But the upgrade guide for v.7.0 shows "mapOptions is removed. Almost all of the options for the native Map class are exposed as props." That said, I can't find reference to hash in the current codebase, and it's not documented in the Map API reference.

Should this work?

tordans commented 12 months ago

That said, I can't find reference to hash in the current codebase, and it's not documented in the Map API reference.

I assume that is because of this...

Aside from the props listed below, the Map component supports all parameters of the Map class constructor (Mapbox | Maplibre). Beware that this is not an exhaustive list of all props. Different base map libraries may offer different options and default values. When in doubt, refer to your base map library's documentation.

Meaning, the docs does not list all props that are just passed to the map library. I was confused by this myself, before.

matburnham commented 12 months ago

And it does work 🤦. I was just being an idiot. I was running my previously compiled code with yarn run start rather than yarn run dev so nothing was ever changing.