how can i add source and layer to my react-map-gl

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

i'm trying to add source and layers on my map and it's not rendering ... import ReactMapGL, {Source, Layer} from 'react-map-gl' const data ... 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 howcaniaddsourceandlayertomyreact-map-gl AskQuestion Asked 1year,6monthsago Modified 1year,6monthsago Viewed 2ktimes 0 i'mtryingtoaddsourceandlayersonmymapandit'snotrenderingeventhoughthemapisbeingrendered. Butwheneverichangethesourcetypetovectoritworked,butthetypeiwanttouseisgeojson(inordertousepolygonsandpolyline),butitdoesn'tseemtowork. Idon'tknowwhati'mdoingwrong,i'vebeentryingtofixthisforhours,evenreadthedocuments,istilldon'tknowwhati'mdoingwrong. hereisthecodebelow. importReactMapGL,{Source,Layer}from'react-map-gl' constdata={ type:"Feature", geometry:{ type:"Polygon", coordinates:[ [ -107.814303, 37.935657 ], [ -107.814424, 37.936094 ], [ -107.816288, 37.936826 ], [ -107.814644, 37.940931 ], [ -107.80993, 37.939892 ], [ -107.807686, 37.939376 ], [ -107.80932, 37.935416 ], [ -107.809507, 37.935014 ], [ -107.810191, 37.934835 ], [ -107.810765, 37.934708 ], [ -107.811377, 37.934732 ], [ -107.813902, 37.935372 ], [ -107.814303, 37.935657 ] ] } } { setViewport(viewport) }} {...viewport} > } Thanksforthehelpinadvance. reactjsmapboxmapbox-gl-jsreact-map-gl Share Improvethisquestion Follow askedDec14,2020at1:30 OgundipePelumiOgundipePelumi 3788bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 1 Maybethisiswhatyouarelookingfor. Share Improvethisanswer Follow answeredDec20,2020at7:15 AaronTomlinsonAaronTomlinson 26544silverbadges1111bronzebadges 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?Browseotherquestionstaggedreactjsmapboxmapbox-gl-jsreact-map-gloraskyourownquestion. TheOverflowBlog ExpertsfromStripeandWaymoexplainhowtocraftgreatdocumentation(Ep.455) Askedandanswered:theresultsforthe2022Developersurveyarehere! FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Testingnewtrafficmanagementtool AskWizardTestResultsandNextSteps Trending:Anewanswersortingoption Related 958 CanyouforceaReactcomponenttorerenderwithoutcallingsetState? 867 HowdoIconditionallyaddattributestoReactcomponents? 926 WhatisthedifferencebetweenReactNativeandReact? 2 HowdoIwritethefollowingMapboxmaplayerinReact.js? 1 HowtodrawadoublelinefromGeoJsonsourceinMapBoxGLJS? 0 MapboxMultiplepolygonsfromsinglegeosonsource 0 React-Map-GL:Howcaniseetheiconswhichicanusebydefaultmapbox-mapsprite? 1 Ican'taddanewlayerafterchangemapstyleinMapboxgljs 3 ReactMapboxlayernotshowing HotNetworkQuestions Arechemicalsusedtoripenfruitindevelopingcountriesharmfultothehealthofconsumers? HowcanIimprovemyphotoofanightcitylandscapewithastarrysky? WhatdoesaProfitFactorof70translatetoinaRogueTraderGame? Aremidi-chloriansstillcanon,despitenotbeingmentionedsinceEpisode1? Howcouldacreaturemakeitsfeathersorhairsglow? Howcandemocracynotbetheruleofthepoor? Differenceusing的here1)这道菜味道很好and2)这道菜的味道很好 HowdoIpolitelycoexistwithahelpvampire? StartupDiskCreatordoesnotexist Maintainingunitformationwhilefollowingpath Howtoplottwofunctions? Whyusedecltypeonatemplateargument? RouteMapping:Roadchoice HowcanImodifythepointofviewofthisphoto? Whatdoes"ifinlocation"contextmeaninNginx? 8vaorclefchange? WhatpossibleretaliationcouldRussiatakeagainstLithuaniaforenforcingtheEUsanctions? Isacrylic/Perspexasuitablematerialforareplacementfridgeshelf? HowdidTgetintotheagency? Ihavetwopassportsfromthesamecountrywithadifferentnamespelling.Issueswhentraveling? What'sareasonablemeansquarederror(orRMSE)? HowcanImakethesesharp,pressedinpartsofaburger? ShouldIcitenon-peerreviewedworkthathelpedinmyresearchinapeer-reviewedpublication? Howtoplayduplicatednoteatthesametime? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-js Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?