Leaflet.Ellipse
plugin could be integrated with react-leaflet
like this:
a) install leaflet-ellipse
package:
npm i leaflet-ellipse
b) introduce the following component to draw an ellipse:
import React, { Component } from "react";
import L from 'leaflet';
import "leaflet-ellipse";
import { withLeaflet } from "react-leaflet";
class Ellipse extends Component {
componentDidMount() {
const { latlng, radii, tilt, options } = this.props;
const { map } = this.props.leaflet;
L.ellipse(latlng, radii, tilt,options).addTo(map);
}
render() {
return null;
}
}
export default withLeaflet(Ellipse);
Usage
class MapExample extends React.Component {
render() {
const { zoom, center } = this.props;
return (
<div>
<Map center={center} zoom={zoom}>
<TileLayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png" />
<Ellipse
latlng={[51.505, -0.05]}
radii={[500, 200]}
tilt={0}
options={{
color: "green",
fillColor: "green",
fillOpacity: 0.5
}}
/>
<Ellipse
latlng={[51.508, -0.12]}
radii={[750, 400]}
tilt={135}
options={{
color: 'red',
fillColor: 'red',
fillOpacity: 0.5
}}
/>
</Map>
</div>
);
}
}
Demo