@urbica/react-map-gl - npm
文章推薦指數: 80 %
Start using @urbica/react-map-gl in your project by running `npm i @urbica/react-map-gl` ... Marker, React Component for Mapbox GL JS Marker.
@urbica/react-map-gl1.15.0 • Public • Published3monthsagoReadmeExploreBETA2Dependencies7Dependents72Versions
UrbicaReactMapboxGLJS
ReactComponentLibraryforMapboxGLJS.MapboxGLJSisaJavaScriptlibrarythatrendersinteractivemapsfromvectortilesandMapboxstylesusingWebGL.ThisprojectisintendedtobeascloseaspossibletotheMapboxGLJSAPI.
Thisprojectisheavilyinspiredbyuber/react-map-gl.
Installation
Components
Usage
StaticMap
InteractiveMap
MapGLwithSourceandLayer
MapGLwithGeoJSONSource
CustomLayerssupport
Documentation
Changelog
License
Contributing
Team
Installation
npminstall--savemapbox-gl@urbica/react-map-gl
...orifyouareusingyarn:
yarnaddmapbox-gl@urbica/react-map-gl
OptionalDependencies
IfyouwanttousetheLanguageControl:
npminstall--save@mapbox/mapbox-gl-language
...orifyouareusingyarn:
yarnadd@mapbox/mapbox-gl-language
Components
Component
Description
MapGL
Representsmaponthepage
MapContext
ReactContextAPIforthemapinstance
Source
Sourcesspecifythegeographicfeaturestoberenderedonthemap
Layer
LayersspecifytheSourcesstyle
Filter
Setfiltertoexistinglayer
CustomLayer
Allowausertorenderdirectlyintothemap'sGLcontext
Image
Addsanimagetothemapstyle
Popup
ReactComponentforMapboxGLJSPopup
Marker
ReactComponentforMapboxGLJSMarker
FeatureState
Setsthestateofageographicfeaturerenderedonthemap
AttributionControl
Representsthemap'sattributioninformation
LanguageControl
Addssupportforswitchingthelanguageofthemapstyle
FullscreenControl
Containsabuttonfortogglingthemapinandoutoffullscreenmode
GeolocateControl
Geolocatetheuserandthentracktheircurrentlocationonthemap
NavigationControl
Containszoombuttonsandacompass
ScaleControl
Displaystheratioofadistanceonthemaptothecorrespondingdistanceontheground
Cluster
ClusterMarkerswithsupercluster
Draw
Supportfordrawingandeditingfeatures
Usage
TouseanyofMapbox’stools,APIs,orSDKs,you’llneedaMapboxaccesstoken.MapboxusesaccesstokenstoassociaterequeststoAPIresourceswithyouraccount.Youcanfindallyouraccesstokens,createnewones,ordeleteexistingonesonyourAPIaccesstokenspage.
SeeDocumentationformoreexamples.
StaticMap
Bydefault,MapGLcomponentrendersinastaticmode.Thatmeansthattheusercannotinteractwiththemap.
importReactfrom'react';
importMapGLfrom'@urbica/react-map-gl';
import'mapbox-gl/dist/mapbox-gl.css';
延伸文章資訊
- 1react-mapbox-gl/API.md at master - GitHub
Add an HTML marker to the map. Note: When rendering many objects, avoid using Marker s as it will...
- 2How to display Markers on a Mapbox Map in React
- 3Search Code Snippets | react map gl marker - Code Grepper
react map gl markerreact-mapbox-gl custom markeradd custom marker in react-mapbox-glreact map gl ...
- 4Marker - react-map-gl
React component that wraps Marker. ... If Marker is mounted with child components, then its conte...
- 5How to display Markers on a Mapbox Map in React
We have our map and our geocoder. We can look up addresses and select one. Let's now display a ma...