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

switching display text from imperial to metric

Open sacdeplastique opened this issue 7 years ago • 2 comments

Whenever I draw a circle with the tool the radius is displayed in feet. I tried changing a few options but no luck. draw={{ metric: true, polyline: { metric: true, }, circle: { metric: true, }, }} edit={{ metric: true, }} Can you please let me know where I could set this feature?

Thank you!

sacdeplastique avatar Mar 22 '17 16:03 sacdeplastique

Would like this as well!

sguergachi avatar Jan 16 '18 18:01 sguergachi

You can pass an object containing settings to EditControl via the "draw" prop like you're doing, the props are just a bit finicky. Setting both metric false AND feet true (or vice-versa) was necessary for me, and you need to do it for each geometry type. I use the following:

Reference: http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html

drawingOptions: (useImperialUnits, showUnits) =>{
			return(
				{
					rectangle: {
						showArea: showUnits,
						showRadius: showUnits,
						feet: useImperialUnits,
						metric: !useImperialUnits,
						nautic: false
					},
					polygon: {
						showArea: showUnits,
						showLength: showUnits,
						showRadius: showUnits,
						feet: useImperialUnits,
						metric: !useImperialUnits,
						nautic: false
					},
					circle: {
						showRadius: showUnits,
						feet: useImperialUnits,
						metric: !useImperialUnits,
						nautic: false
					},
					polyline: {
						showLength: showUnits,
						feet: useImperialUnits,
						metric: !useImperialUnits,
						nautic: false
					}
				}
			);


feralresearch avatar Sep 08 '18 15:09 feralresearch