0.1.6 • Published 6 years ago

react-leaflet-locate-control v0.1.6

Weekly downloads
458
License
MIT
Repository
github
Last release
6 years ago

react-leaflet-locate-control

Plugin for React-Leaflet to display locate control

Thanks to https://github.com/domoritz/leaflet-locatecontrol/ on which this react plugin is 100% based on.

Example

Demo MyRoutes.io

Installation

yarn add react-leaflet-locate-control
// Import the package
import LocateControl from 'react-leaflet-locate-control'

// Setup LocateControl options
const locateOptions = {
  position: 'topright',
  strings: {
      title: 'Show me where I am, yo!'
  },
  onActivate: () => {} // callback before engine starts retrieving locations
}

// Inside your <Map> component add LocateControl
<Map>
  <LocateControl options={locateOptions} startDirectly/>
</Map>

startDirectly : Instantly start the locate control

Options

OptionTypeDescriptionDefault
positionstringPosition of the controltopleft
layerILayerThe layer that the user's location should be drawn on.a new layer
setViewboolean or stringSet the map view (zoom and pan) to the user's location as it updates. Options are false, 'once', 'always', and 'untilPan'untilPan
flyTobooleanSmooth pan and zoom to the location of the marker. Only works in Leaflet 1.0+.false
keepCurrentZoomLevelbooleanOnly pan when setting the view.false
clickBehaviorobjectWhat to do when the user clicks on the control. Has two options inView and outOfView. Possible values are stop and setView.{inView: 'stop', outOfView: 'setView'}
returnToPrevBoundsbooleanIf set, save the map bounds just before centering to the user's location. When control is disabled, set the view back to the bounds that were saved.false
cacheLocationbooleanKeep a cache of the location after the user deactivates the control. If set to false, the user has to wait until the locate API returns a new location before they see where they are again.
drawCirclebooleanIf set, a circle that shows the location accuracy is drawn.true
drawMarkerbooleanIf set, the marker at the users' location is drawn.true
markerClassclasshe class to be used to create the marker.L.CircleMarker
circleStylePath optionsAccuracy circle style properties.see code
markerStylePath optionsInner marker style properties. Only works if your marker class supports setStyle.see code
followCircleStylePath optionsChanges to the accuracy circle while following. Only need to provide changes.{}
followMarkerStylePath optionsChanges to the inner marker while following. Only need to provide changes.{}
iconstringThe CSS class for the icon.fa fa-map-marker
iconLoadingstringThe CSS class for the icon while loading.fa fa-spinner fa-spin
iconElementTagstringThe element to be created for icons.span
circlePaddingarrayPadding around the accuracy circle.[0, 0]
createButtonCallbackfunctionThis callback can be used in case you would like to override button creation behavior.see code
onLocationErrorfunctionThis even is called when the user's location is outside the bounds set on the map.see code
onLocationOutsideMapBoundsfunctionUse metric units.see code
showPopupbooleanDisplay a pop-up when the user click on the inner marker.true
stringsobjectStrings used in the control. Options are title, metersUnit, feetUnit, popup, and outsideMapBoundsMsgsee code
locateOptionsLocate optionsThe default options passed to leaflets locate method.see code
onActivatefunctionCallback to add logic before the location engine starts working.

Go to https://github.com/domoritz/leaflet-locatecontrol/

Dependencies

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago