henrythasler / Leaflet.Geodesic

Add-on to draw geodesic lines with leaflet
GNU General Public License v3.0
156 stars 27 forks source link

Calling getBounds on a GeodesicCircle throws an error #48

Closed jziggas closed 4 years ago

jziggas commented 4 years ago

I have a FeatureGroup that can contain a number of Rectangles, Circles, or GeodesicCircles. On page load I call map.fitResults(featureGroup.getBounds()) to zoom in and fit the view of the map to nicely contain all of the geoshapes. It looks like calling getBounds() on a FeatureGroup internally calls getBounds() on each of the underlying layers, but GeodesicCircle doesn't have that method and an error gets thrown when that layer is reached.

Polylines however do have the getBounds() method and I was able to temporarily resolve this issue by defining a new method on each instance of a GeodesicCircle:

circle = L.geodesiccircle(...)
(circle as any).getBounds = () => circle.polyline.getBounds();
henrythasler commented 4 years ago

I agree. This, and maybe other methods, need to be included in the geodesic-classes.

jziggas commented 4 years ago

Yeah there may be more missing methods but that's as far as I went with it. I noticed GeodesicCircleClass extends L.Layer but it almost seems like it should be extending or otherwise also inheriting (mixin?) from L.Circle to get those methods. 🤷‍♂

henrythasler commented 4 years ago

Related code in leaflet.js: https://github.com/Leaflet/Leaflet/blob/441c5fb0a877ada5d055f0d5f1fa1db8ce7c2957/src/layer/FeatureGroup.js#L84

henrythasler commented 4 years ago

Release is v2.3.1

jziggas commented 4 years ago

Thanks!