react-map-gl Marker is moving when zooming the map

文章推薦指數: 80 %
投票人數:10人

I tried to add a marker, but the marker keeps moving when I zoom. What is causing this to happen? import MapGL, { Marker } from "react-map- ... Resultsfromthe2022DeveloperSurveyarehere. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore react-map-glMarkerismovingwhenzoomingthemap AskQuestion Asked 4monthsago Modified 4monthsago Viewed 664times 1 I'vebuiltaReactappwithamapcomponentwhichrendersamap.Itriedtoaddamarker,butthemarkerkeepsmovingwhenIzoom.Whatiscausingthistohappen? importMapGL,{Marker}from"react-map-gl" import{useState}from"react"; constMap=()=>{ const[viewState,setViewState]=useState({ longitude:4.895168, latitude:52.370216, zoom:10, }) const[marker]=useState({ longitude:4.895168, latitude:52.370216, }) return( setViewState(evt.viewState)} mapboxAccessToken="my_token" > ) } exportdefaultMap; reactjsmapboxreact-map-gl Share Follow askedFeb6at15:17 TimMGTimMG 33622silverbadges1313bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 2 Theproblemwasthismissinglineinmyindex.html: Thedocumentationtellsyounothingaboutit,hadtofinditinthesourcecodeofthisexample:https://github.com/visgl/react-map-gl/tree/7.0-release/examples/controls Share Follow answeredFeb6at18:22 TimMGTimMG 33622silverbadges1313bronzebadges 1 igetcorserrorusingthis – Farhad May30at13:54 Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedreactjsmapboxreact-map-gloraskyourownquestion. TheOverflowBlog ExpertsfromStripeandWaymoexplainhowtocraftgreatdocumentation(Ep.455) Askedandanswered:theresultsforthe2022Developersurveyarehere! FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Testingnewtrafficmanagementtool AskWizardTestResultsandNextSteps Trending:Anewanswersortingoption Related 1069 React-routerURLsdon'tworkwhenrefreshingorwritingmanually 712 WhatisthedifferencebetweenstateandpropsinReact? 635 What'sthedifferencebetween"super()"and"super(props)"inReactwhenusinges6classes? 692 WhatisthedifferencebetweenusingconstructorvsgetInitialStateinReact/ReactNative? 926 WhatisthedifferencebetweenReactNativeandReact? 654 HowtofixmissingdependencywarningwhenusinguseEffectReactHook 1 Togglingbetweenanimagegridandimagesliderwithonearrayofimagesinreacthooks 2 ConvertaPoint(orPointLike)toLngLatobject HotNetworkQuestions Runningfiberline ShouldIcitenon-peerreviewedworkthathelpedinmyresearchinapeer-reviewedpublication? Lookingfornoir-ishsci-fi"story"setonMars,readinpastdecadebut Whatisthemeaningof"payinginbuttons"? Howtallarethemushrooms? DoesaneoclassicalproductionwithconstantreturnstoscaleimpliestypeofCobb-Douglas Whatisthelong-termprofessionalstatusofaspousalhire? Arechemicalsusedtoripenfruitindevelopingcountriesharmfultothehealthofconsumers? Whydidmybicyclehaveaspokeshatterandatuberupture? Isthereanysignificantdifferencebetween駆け回るand駆け巡る? Howdoyoudiplomaticallycallasituation'verybad'inaresume-likedocument? IterativeSmallestComplement Willmymeatloafcookifthesauceismixedintothemeat Findthewalls! Ifaplayercastsaspellofunlimiteddurationandretrainsoutofit,doesthespellremainactive? Operationalizingthedefinitionof"datingrelationship"infederalUSdomesticviolencelaw CanIasktobeconsideredforanotheropeninginsamegroup? ExportingresultscontainingEntitiestoJSON? WhatisthepurposeofthefuelpumpsintheA320? Canimaginary(illusionary)forcescauseacceleration,andwhatexactlyarethey? WhatpossibleretaliationcouldRussiatakeagainstLithuaniaforenforcingtheEUsanctions? DC/DCConverternotoutputtingthecorrectvoltage Auto-Launchappfromthedmg Kakeyacrossed-needlesproblem morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-js Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?