react-leaflet-measure icon indicating copy to clipboard operation
react-leaflet-measure copied to clipboard

L.Control.Measure is not a constructor error

Open inclunav opened this issue 3 years ago • 0 comments

I am getting L.Control.Measure is not a constructor error.While implmeneting here is my code snippet import React from "react"; import { Map, Marker, Popup, TileLayer, MapControl, withLeaflet, FeatureGroup, Circle, GeoJSON } from "react-leaflet";

import MeasureControlDefault from 'react-leaflet-measure';

// Wrap our new variable and assign it to the one we used before. The rest of the codes stays the same. const MeasureControl = withLeaflet(MeasureControlDefault);

class LeafletDraw extends React.Component { constructor(props) { super(props); this.measureStart = this.measureStart.bind(this); this.measureFinish = this.measureFinish.bind(this); }

measureStart(e) { console.log(e); }

measureFinish(e) { console.log(e); }

render() { const measureOptions = { position: 'topright', primaryLengthUnit: 'meters', secondaryLengthUnit: 'kilometers', primaryAreaUnit: 'sqmeters', secondaryAreaUnit: 'acres', activeColor: '#db4a29', completedColor: '#9b2d14' }; return ( <Map center={[2.935403, 101.448205]} zoom={10} onMeasurestart={this.measureStart} onMeasurefinish={this.measureFinish}> <TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" attribution='© OpenStreetMap contributors' /> {/* <MeasureControl {...measureOptions} /> */} <MeasureControl /> </Map> ); } }

export default LeafletDraw;

Error is here: TypeError: L.Control.Measure is not a constructor Function.L.control.measure node_modules/react-leaflet-measure/dist/react-leaflet-measure.min.js:1

inclunav avatar Mar 15 '21 07:03 inclunav