Skip to content

Object returned from useMap() missing addSource() and addLayer() methods in maplibre-based map #2233

Answered by Pessimistress
wdawson61 asked this question in Q&A
Discussion options

You must be logged in to vote

From the documentation:

The MapRef object exposes Map methods that are safe to call without breaking the React bindings. For example, setStyle() is hidden from the ref object, because the style is supposed to be changed by updating the mapStyle prop. Calling the method directly may cause the the React prop to mismatch with the underlying state, and lead to unexpected behaviors.

You can still access the hidden members via getMap()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wdawson61
Comment options

Answer selected by wdawson61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants