Dynamically changing the layer order is not possible #939
文章推薦指數: 80 %
Hello, In my use case I have a list of layers whose order can be messed up with. I made this sandbox to test the behaviour of inverting the ...
Skiptocontent
{{message}}
visgl
/
react-map-gl
Public
Notifications
Fork
1.2k
Star
6.6k
Code
Issues
11
Pullrequests
5
Discussions
Actions
Security
Insights
More
Code
Issues
Pullrequests
Discussions
Actions
Security
Insights
Newissue
Haveaquestionaboutthisproject?SignupforafreeGitHubaccounttoopenanissueandcontactitsmaintainersandthecommunity.
Pickausername
EmailAddress
Password
SignupforGitHub
Byclicking“SignupforGitHub”,youagreetoourtermsofserviceand
privacystatement.We’lloccasionallysendyouaccountrelatedemails.
AlreadyonGitHub?
Signin
toyouraccount
Jumptobottom
Dynamicallychangingthelayerorderisnotpossible
#939
Open
adrienjopenedthisissue
Nov13,2019
·5comments
Open
Dynamicallychangingthelayerorderisnotpossible
#939
adrienjopenedthisissue
Nov13,2019
·5comments
Labels
feature
Comments
Copylink
adrienj
commented
Nov13,2019
•
edited
Hello,InmyusecaseIhavealistoflayerswhoseordercanbemessedupwith.
Imadethissandboxtotestthebehaviourofinvertingthesecondandthirditemsinalistoffour.Theseconditemisputatthetopofthelayering.
Reproducethebug:
https://codesandbox.io/s/shy-waterfall-fwky3
Itriedaddingthearrayindexinthelayerkeybutthethirdlayergoestothetopinsteadofbellowtheforth.Maybethisisbecausetheforthlayer'skeydidn'tchange,soitisnotkeptaboveallotherlayers?
Ialsotriedusingarandomkeyforthelayers.Thiseliminatestheorderissuebutmightbebadforperformance.InthesecondsandboxItriedtodynamicallychangethekeyofthelayersonlyafterachangeinorderandnotoneveryrender.
Expectedbehaviour:
https://codesandbox.io/s/brave-firefly-zr9oc
Ifafixmightbreakotherusecases,maybeanewproptotheLayercomponentthatspecifywewanttokeeptheordercouldbepossible?
Thanks
Thetextwasupdatedsuccessfully,buttheseerrorswereencountered:
Allreactions
Copylink
Collaborator
Pessimistress
commented
Jan6,2020
YoushouldbeabletoreorderbychangingthebeforeIdprop.
👍
1
chriszrcreactedwiththumbsupemoji
Allreactions
👍
1reaction
Sorry,somethingwentwrong.
Copylink
yurivangeffen
commented
Apr29,2020
Ipersonallyfindthisaveryminimalsolutionthatdoesn'treallyworkifyouwanttoswitchlayersinandoutdynamically.Nowallofasuddenmylayercomponentsneedtoknowofthestateofallotherlayers,weitherthey'reshownornot,etc...Iknowthisiswhat'sexposedbymapbox,butisthereanotherwaytodoorderingproperly,throughkeyforexample?
👍
3
adrienj,maxwell-oroark,andMattReimerreactedwiththumbsupemoji
Allreactions
👍
3reactions
Sorry,somethingwentwrong.
Copylink
yurivangeffen
commented
May7,2020
Iusedadifferentwayoffixingthisformyspecificusecase:
Createsomelayersthatarealwayssortedrelativetoeachother.Theyshouldn'thaveanycontent,sowhatIdoisusethe'background'typeandsetvisibilityto'none',e.g.:
['baselayer','some_other_layer','yet_another_one'].map(name=>{
return(
延伸文章資訊
- 1Layer — Urbica React Map GL
Except for layers of the background type, each layer needs to refer to a source. Layers take the ...
- 2A Complete Guide to Sources and Layers in React and ...
We will use Mapbox GL JS and React to build an interactive map with several custom sources and la...
- 3react-map-gl-draw - npm
A lite version editing layer with react. Latest version: 1.0.3, last published: 2 months ago. Sta...
- 4MAP integration in React with react-map-gl and deck-gl
- 5how can i add source and layer to my react-map-gl
i'm trying to add source and layers on my map and it's not rendering ... import ReactMapGL, {Sour...