how can i add source and layer to my react-map-gl
文章推薦指數: 80 %
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
]
]
}
}
延伸文章資訊
- 1Layer - react-map-gl
This component allows apps to create a map layer using React. import * as React from 'react'; imp...
- 2react-map-gl - npm
React components for Mapbox GL JS-compatible libraries. Latest version: 7.0.16, last published: 6...
- 3react-map-gl-draw - npm
A lite version editing layer with react. Latest version: 1.0.3, last published: 2 months ago. Sta...
- 4how 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...
- 5A 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...