IvanSanchez / Leaflet.ImageOverlay.Rotated

Displays rotated/slanted image overlays in Leaflet
93 stars 24 forks source link

Layer doesn't work correctly in L.FeatureGroup, due to missing _bounds attribute #4

Open carpiediem opened 7 years ago

carpiediem commented 7 years ago

I tried to include some Leaflet.ImageOverlay.Rotated layers in a feature group, but the L.FeatureGroup methods weren't working correctly. It appears this is due to not getting bounding data from the Leaflet.ImageOverlay.Rotated object.

I was able to make a temporary solution by adding the second line of code, below.

    var overlay = L.imageOverlay.rotated(imageURL, topLeft, topRight, bottomLeft);
    overlay._bounds = L.latLngBounds([topLeft, topRight, bottomRight, bottomLeft]);

Perhaps the library could do this automatically?

IvanSanchez commented 7 years ago

This is already done at https://github.com/IvanSanchez/Leaflet.ImageOverlay.Rotated/blob/gh-pages/Leaflet.ImageOverlay.Rotated.js#L129 .

Can you publish a fiddle/codepen/playground that displays this behaviour? That should make it easier to see where the FeatureGroup needs the _bounds, and how to refactor the bounds-calculating code so it can run earlier.