React-mapbox-gl: Unable to hook into Mapbox API for adding ...
文章推薦指數: 80 %
I am using react-mapbox-gl in my next application, according to the documentation: onStyleLoad: (map, loadEvent) => void called with the ... 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-mapbox-gl:UnabletohookintoMapboxAPIforadding3Dterraintoamap AskQuestion Asked 1monthago Modified 1monthago Viewed 61times 1 Iamusingreact-mapbox-glinmynextapplication,accordingtothedocumentation: onStyleLoad:(map,loadEvent)=>voidcalledwiththeMapboxMap instancewhentheloadeventisfired.Youcanusethecallback's firstargumenttotheninteractwiththeMapboxAPI. ThisexposesapropwhichallowsonetointeractwithMapboxAPIdirectly,andthathasworkedinregardstoaddingaGeocoderandGeoLocationControlbutdoesnotworkinregardstoadding3dterrain. Thisismymapcomponent: import{useCallback,useEffect,useRef}from'react' importReactMapboxGl,{RotationControl,ZoomControl}from"react-mapbox-gl"; importmapboxglfrom'mapbox-gl'; importMapboxGeocoderfrom'@mapbox/mapbox-gl-geocoder'; constmapAccess={ mapboxApiAccessToken:process.env.MAPBOX_ACCESS_TOKEN } constMap=ReactMapboxGl({ accessToken:process.env.MAPBOX_ACCESS_TOKEN, logoPosition:'bottom-right', pitchWithRotate:true }); exportdefaultfunctionMyMap(){ return( <> > ) } Anyideawhythisisnotworking? Thanksinadvance! reactjsmapbox-gl-jsreact-mapbox-gl Share Follow askedMay6at14:01 AntonioPavicevac-OrtizAntonioPavicevac-Ortiz 6,1891111goldbadges4747silverbadges119119bronzebadges Addacomment | 0 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) Knowsomeonewhocananswer?Sharealinktothisquestionviaemail,Twitter,orFacebook. 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 Browseotherquestionstaggedreactjsmapbox-gl-jsreact-mapbox-gloraskyourownquestion. TheOverflowBlog ExpertsfromStripeandWaymoexplainhowtocraftgreatdocumentation(Ep.455) Askedandanswered:theresultsforthe2022Developersurveyarehere! FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Testingnewtrafficmanagementtool AskWizardTestResultsandNextSteps Trending:Anewanswersortingoption Related 3 AddingaTilesetfrommapboxintomymap 428 ReactHookWarningsforasyncfunctioninuseEffect:useEffectfunctionmustreturnacleanupfunctionornothing 1 uber/react-map-glgetMap&exposedMapboxAPI 3 ReactMapBoxGLgeocoderinputoutsidethemapisthatpossible? 3 CustomDEMfor3DTerraininMapboxGLJSV2 0 React+MapboxGL:StateofArrayofMapComponentsnotupdatingonMapEvent 0 Mapbox&React:Unabletoinputvaluesintosearchbox 0 SizeofthemapwhenredenringmapboxinReact HotNetworkQuestions ExportingresultscontainingEntitiestoJSON? Howisenergy"storedinanelectricfield"? Howcandemocracynotbetheruleofthepoor? WouldpubliclyfartingonapictureoftheEnglishmonarchactuallyqualifyastreasonin1798? WeknowClassicalMechanicsiswrong.ButcanwealsosayeveryothertheoryiswrongexcepttheTheoryofEverything? Runningfiberline Doestheuseoffrontsuspensionnegativelyaffectroadridingefficiency? Ifaplayercastsaspellofunlimiteddurationandretrainsoutofit,doesthespellremainactive? BookaboutanaliencivilizationthatsendskidstoberaisedonEarth HowdidTgetintotheagency? InP.J.Plauger's"TheStandardCLibrary"(1992),whyareforloopsusedsofrequentlyinsteadofwhileloopsintheimplementations? Canaclericofthegrave'sgodbeSarenrae? NaturalMedicinewithBattleMedicine Differenceusing的here1)这道菜味道很好and2)这道菜的味道很好 DC/DCConverternotoutputtingthecorrectvoltage Whatdoyoucallthepointypartsofatextbubblethat'snotthetail? HowdoesanObjectateventhorizonstoptotheobserver? Whatarebestpracticesfortestingtheabsenceoffunctionality Maintainingunitformationwhilefollowingpath ShouldIcitenon-peerreviewedworkthathelpedinmyresearchinapeer-reviewedpublication? Whatdoes"ifinlocation"contextmeaninNginx? HowcanIimprovemyphotoofanightcitylandscapewithastarrysky? IntheISO1990Cstandardlibrary,whatwastherationaleforhavingmemcpyreturnoneofitsinputs? Whyusedecltypeonatemplateargument? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-js Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1A React binding of mapbox-gl-js - GitHub
ReactMapboxGL · Layer & Feature. property symbol displays a mapbox symbol. property line displays...
- 2Use Mapbox GL JS in a React App
Mapbox GL JS is part of the Mapbox GL ecosystem, which also provides native SDKs for Android, iOS...
- 3visgl/react-map-gl: React friendly API wrapper around ... - GitHub
react-map-gl is a suite of React components designed to provide a React API for Mapbox GL JS-comp...
- 4react-map-gl | Introduction
- 5react-map-gl examples - CodeSandbox
Learn how to use react-map-gl by viewing and forking react-map-gl example apps on CodeSandbox.