1.0.1 • Published 5 years ago

react-leaflet-box-select-measurement-private v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

react-leaflet-box-zoom

A Box zoom tool for React Leaflet

NPM JavaScript Style Guide

About

A box zoom tool for React Leaflet.

npm.io

Installation

npm install --save react-leaflet-box-zoom

yarn install

Usage

import React, { Component } from 'react'
import { Map, TileLayer, ZoomControl } from 'react-leaflet'

import { BoxZoomControl } from 'react-leaflet-box-zoom'

export default class App extends Component {

  render () {

    return (
      <div className="map">
        <Map
          center={[44.635, 22.653]}
          zoom={12}
          zoomControl={false} >

          <TileLayer
            attribution=""
            url="https://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"/>
			
          <ZoomControl position="topright" />

          <BoxZoomControl 
            position="topright"
            sticky={true}
          />

        </Map>
      </div>
    )
  }
}

Ref control

You can programatically start and stop the box zoom tool by using a ref

<BoxZoomControl ref={(ref) => this.boxZoomControlRef = ref} />

// elsewhere
this.boxZoomControlRef.stop();
this.boxZoomControlRef.start();

Props

NameDefaultDescription
stickyfalseSetting to true will cause the zoom control to remain active after the user has zoomed
positiontopleftPosition of the control. Valid values are topleft, topright, bottomleft, or bottomright
styleA react css style prop for the button. You can pass in your own style such as a custom background image. The default is set to match the default Leaflet style with a box zoom icon
activeStyleA react css style prop for the active state of the button. This appends to the style prop.

License

MIT © ChrisLowe-Takor