Introduction To MapBox With React | MindBowser

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

Introduction To MapBox With React ... Mapbox is an American provider of custom online maps based on open-source maps and libraries like OpenStreetMap(default map ... IntroductionToMapBoxWithReactTechnologyBlogsshareonMapboxisanAmericanproviderofcustomonlinemapsbasedonopen-sourcemapsandlibrarieslikeOpenStreetMap(defaultmapsolution),theMBTilesspecification,LeafletJavaScriptlibrary,andtheCartoCSSmapstylinglanguageandparseretc.MapBoxprovidesmaps,navigationsolutions,datavisualizationetc.Itisanall-in-onesolutionformap-basedproblems.Mapboxisa locationdataplatformthatpowersthemapsandlocationservicesusedinmanypopularappslikeSnapchat,Facebook,foursquare,MongoDBetc.MapboxReactIntegrationMapboxgivesofficialdocumentationtogetstartedwithMapboxinreact(#3).TherearealsomanywrapperspackagesofMapboxforreactforsomeadvanceusagessomeofthemareasfollows:ReactMapboxGL(react-mapbox-gl).ReactMapGL(react-map-gl).Inthisblog,wewilluseReactMapGL.ThislibraryisdevelopedbyUberandprobablyhasmorefunctionalitythanmostprojectswouldeverrequire. *InstallationUsingreact-map-glrequiresreact>=16.3.npminstallreact-map-gl oryarnaddreact-map-glStyling:ThecurrentMapbox-glreleaserequiresitsstylesheettobeincludedatalltimes.Themarker,popupandnavigationcomponentsinreact-map-glalsoneedthestylesheettoworkproperly.Youmayaddthestylesheettotheheadofyourpage:/mapbox-gl.css'rel='stylesheet'/>FindoutyourMapboxversionbyrunningyarnlistMapbox-glornpmlsMapbox-gl.Orembeditinyourappbyusing–browserify-csswithBrowserifyor–css-loaderwithWebpack://app.js import'mapbox-gl/dist/mapbox-gl.css'; OrreferhereExampleimport{useState}from"react"; importReactMapGLfrom"react-map-gl"; //MapBoxDefaultStyles constMapboxStreets="mapbox://styles/mapbox/streets-v11"; constMapboxOutDoor="mapbox://styles/mapbox/outdoors-v11"; constMapboxLight="mapbox://styles/mapbox/light-v10"; constMapboxDark="mapbox://styles/mapbox/dark-v10"; constMapboxSatellite="mapbox://styles/mapbox/satellite-v9"; constMapboxSatelliteStreet="mapbox://styles/mapbox/satellite-streets-v11"; constMapboxNavigationDay="mapbox://styles/mapbox/navigation-day-v1"; constMapboxNavigationNight="mapbox://styles/mapbox/navigation-night-v1"; //MapBoxCustomstyles constCustom1="mapbox://styles/examples/cke97f49z5rlg19l310b7uu7j"; constCustom2="mapbox://styles/surajfc/ckq0jexlc0h4418k00g3y1ora/draft"; constStarterMap=({token})=>{  const[viewport,setViewport]=useState({ width:"100vw", height:"100vh", latitude:18.5204, longitude:73.8567, zoom:8,  });  return( setViewport(nextViewport)}  mapStyle={Custom1} />  ); }; exportdefaultStarterMap;FormoremapStyleplsreferhere wecanalsocreatecustommapstylesusingMapboxstudio*AddingaNavigationControlimport*asReactfrom'react'; importReactMapGL,{NavigationControl}from"react-map-gl"; constMAPBOX_TOKEN='';//Setyourmapboxtokenhere constMap=()=>{  const[viewport,setViewport]=React.useState({   latitude:37.7577,   longitude:-122.4376,   zoom:8  }); constnavControlStyle={  right:10,  bottom:10, };  return(          ); } Wecanseeanavigationcontrolwithazoomoptionatthebottomright.*GetuserGeolocationwithFullScreenimportReact,{useState}from"react"; importReactMapGL,{ FullscreenControl, GeolocateControl, FlyToInterpolator, }from"react-map-gl"; //buttonpositionforgoingtousercurrentlocation constgeolocateControlStyle={ left:10, top:10, }; //btnPosiitonoffullscreentoggle constfullscreenControlStyle={ right:10, top:10, }; constGeoLocateMap=({token})=>{ const[viewport,setViewport]=useState({  width:"100vw",  height:"100vh",  latitude:18.5204,  longitude:73.8567,  zoom:8, }); return(  

  setViewport(nextViewport)}    transitionDuration={2000}    transitionInterpolator={newFlyToInterpolator()}   >             
); }; exportdefaultGeoLocateMap; *MapwithCustomMarkerimportReact,{useState}from"react"; importReactMapGL,{Marker}from"react-map-gl"; importLocationfrom"../location.png"; constMarkerMap=({token})=>{ const[viewport,setViewport]=useState({  width:"100vw",  height:"100vh",  latitude:18.5204,  longitude:73.8567,  zoom:8, }); return(  
  setViewport(nextViewport)}   >              

MindBowser

   
  
 
); }; exportdefaultMarkerMap; FindthecodehereThesearesomeexamplesofMapboxwithreact.REFERENCE:https://uptech.team/blog/mapbox-vs-google-maps-vs-openstreetmaphttps://en.wikipedia.org/wiki/Mapboxhttps://docs.mapbox.com/help/tutorials/use-mapbox-gl-js-with-react/https://blog.logrocket.com/react-map-library-comparison/https://visgl.github.io/react-map-gl/SurajFullStackSoftwareDeveloperSurajisafull-stackdeveloperwitharound1yearofexperienceindevelopingwebapplications.HehasknowledgeofReactJs,Javascript,andPythonDjangoframework.Also,hasexperienceincreatingRESTAPIs,developingwebapplicationsusingpython,andreact.HowtoEffectivelyHireandManageaRemoteTeamofDevelopers.DownloadNowSubscribetoOurNewsletterGetthelatestupdatesbysharingyouremail.KeepReadingTechnologyBlogsACompleteGuidetoBuildtheFirstReactNativeAppReadMoreTechnologyBlogsReactJSvsReactNative–A2022OverviewforyourBusinessGrowthReadMoreTechnologyBlogsReactGoogleMapWithACustomPinMarkerReadMoreKeepReadingTechnologyBlogsACompleteGuidetoBuildtheFirstReactNativeAppReadMoreTechnologyBlogsReactJSvsReactNative–A2022OverviewforyourBusinessGrowthReadMoreTechnologyBlogsReactGoogleMapWithACustomPinMarkerReadMoreGettheanswertofrequentlyaskedquestionsbyfoundersforfounders!DownloadNowLookingtoHireaWebDevelopmentTeam?FlexibleEngagementModel|Secure&ScalableApps|FirstTimeRightProcess4,200+ProjectsLaunched2,500+SatisfiedCustomers2,000+ManYearsExp97%+ClientRetentionContactUsNowGetintouchforadetaileddiscussion.HearFromOur100+CustomersMindbowserhelpedusbuildanawesomeiOSapptobringbalancetopeople’slives.ADDIEWOOTTENCEO,SMILINGMINDWehadveryclosegolivetimelineandMindBowserteamgotusliveamonthbefore.ShazKhanCEO,BuyNowWorldWideTheywereaveryresponsiveteam!Extremelyeasytocommunicateandworkwith!KristenM.Founder&CEO,TotTechWe’vehadverylittle-to-nohiccupsatall—it’sbeenareallypleasurableexperience.ChackoThomasCo-Founder,TEAM8sMindbowserisoneofthereasonsthatourappissuccessful.Theseguyshavebeenagreatteam.DaveDubierFounder&CEO,MangoMirrorMindbowserwasveryhelpfulwithexplainingthedevelopmentprocessandstartedquicklyontheproject.HieuLeExecutiveDirectorofProductDevelopment,InnovationLabThegreatestbenefitwegotfromMindbowseristheexpertise.Theirteamhasdevelopedappsinalldifferentindustrieswithalltypesofsocialproofs.AlexGobelCo-Founder,VesicaMindbowserisprofessional,efficientandthorough. MacKenzieRConsultantatXPRIZEVerycommitted,theycreatebeautifulappsandareverybenevolent.TheyhavebrilliantIdeas.LaurieMastrogianiFounder,S.T.A.R.SofWellnessMindBowserwasgreat;theylistenedtousalotandhelpedushoneinontheactualideaoftheapp.”“Theyhadputtogetherfantasticwireframesforus.BennetGilloglyCo-Founder,FlatEarthThey'reverytech-savvy,yethumble.UmaNidmartyCEO,GSAdvisorate,Inc.Ayushwasresponsiveandpairedmewiththebestteammemberpossible,tocompletemycomplexvisionandproject.Couldnotbehappier.KatieTaylorFounder,ChildLifeOnCallAsafounderofabuddingstart-up,ithasbeenagreatexperienceworkingwithMindbowerIncunderAyush'sleadershipforouronlinedigitalplatformdesignanddevelopmentactivity.RadhikaKotwalFounderofCourtyardlyTheteamfromMindbowserstayedontask,askedtherightquestions,andcompletedtherequiredtasksinatimelyfashion!Strongworkteam!MichaelWrightChiefExecutiveOfficer,SDOH2HealthLLCTheyarefocused,patientand;theyareinnovative.Pleasegivethemashotifyouarelookingforsomeonetopartnerwith,youcangoalongwithMindbowser.DavidCainCEO,thirty2giveWeareasmallnon-profitonabudgetandtheywereabletodelivertheirworkatourprescribedbudgets.TheirteamalwaysmettheirobjectivesandI'mveryhappywiththeendresult.Thankyou,Mindbowserteam!!BartMendelFounder,Mindworks



請為這篇文章評分?