Marker - react-map-gl
文章推薦指數: 80 %
React component that wraps Marker. ... If Marker is mounted with child components, then its content will be rendered to the specified location. If it is mounted ... ChevronDownIntroductionIntroductionWhat'snewUpgradeGuideContributingtoreact-map-glChevronDownDeveloperGuideGetStartedAboutMapboxTokensStateManagementAddingCustomDataTipsandTricksChevronDownAPIReferencedefault(Map)AttributionControlFullscreenControlGeolocateControlLayerMapProviderMarkerNavigationControlPopupScaleControlSourceuseControluseMapTypesMarkerReactcomponentthatwrapsMarker.import*asReactfrom'react'; importMap,{Marker}from'react-map-gl'; functionApp(){ return; }IfMarkerismountedwithchildcomponents,thenitscontentwillberenderedtothespecifiedlocation.Ifitismountedwithnocontent,thenadefaultmarkerwillbeused.PropertiesRenderoptionsanchor:'center'|'left'|'right'|'top'|'bottom'|'top-left'|'top-right'|'bottom-left'|'bottom-right'Default:'center'AstringindicatingthepartoftheMarkerthatshouldbepositionedclosesttothecoordinatesetvialongitudeandlatitude.color:stringDefault:'#3FB1CE'Thecolortouseforthedefaultmarkerifthecomponentcontainsnocontent.clickTolerance:numberDefault:null(inheritsMap'sclickTolerance)Themaxnumberofpixelsausercanshiftthemousepointerduringaclickonthemarkerforittobeconsideredavalidclick(asopposedtoamarkerdrag).draggable:booleanDefault:falseIftrue,themarkerisabletobedraggedtoanewpositiononthemap.latitude:numberRequired.Thelatitudeoftheanchorlocation.longitude:numberRequired.Thelongitudeoftheanchorlocation.offset:PointLikeDefault:nullTheoffsetinpixelsasaPointLikeobjecttoapplyrelativetotheelement'scenter.Negativesindicateleftandup.pitchAlignment:'map'|'viewport'|'auto'Default:'auto'mapalignstheMarkertotheplaneofthemap.viewportalignstheMarkertotheplaneoftheviewport.autoautomaticallymatchesthevalueofrotationAlignment.rotation:numberDefault:0Therotationangleofthemarkerindegrees,relativetoitsrotationAlignmentsetting.Apositivevaluewillrotatethemarkerclockwise.rotationAlignment:'map'|'viewport'|'auto'Default:'auto'mapalignstheMarker'srotationrelativetothemap,maintainingabearingasthemaprotates.viewportalignstheMarker'srotationrelativetotheviewport,agnostictomaprotations.autoisequivalenttoviewport.scale:numberDefault:1Thescaletouseforthedefaultmarkerifthecomponentcontainsnocontent. Thedefaultscale(1)correspondstoaheightof41pxandawidthof27px.Thispropisnotreactive(onlyusedwhenthemarkerismounted).style:CSSPropertiesCSSstyleoverridethatappliestothemarker'scontainer.CallbacksonClick:(evt:MapEvent)=>voidCalledwhenthemarkerisclickedon.onDragStart:(evt:MarkerDragEvent)=>voidCalledwhendraggingstarts,ifdraggableistrue.onDrag:(evt:MarkerDragEvent)=>voidCalledwhiledragging,ifdraggableistrue.onDragEnd:(evt:MarkerDragEvent)=>voidCalledwhendraggingends,ifdraggableistrue.Sourcemarker.ts
延伸文章資訊
- 1@urbica/react-map-gl - npm
Start using @urbica/react-map-gl in your project by running `npm i @urbica/react-map-gl` ... Mark...
- 2Mapbox Marker Clustering in React - Morioh
Even at hundreds of markers using Mapbox via react-map-gl, you may feel it start to lag. By clust...
- 3Add custom markers in Mapbox GL JS | Help
- 4How 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...
- 5react-map-gl Marker is moving when zooming the map
I tried to add a marker, but the marker keeps moving when I zoom. What is causing this to happen?...