IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
285 stars 110 forks source link

draw-tools: Circle edit is broken #174

Closed johnd0e closed 4 years ago

johnd0e commented 5 years ago

Just drawn circle can be edited without problems. But after we reload page and press edit button - there is exception.

VM16179:2760 Uncaught Error: Invalid LatLng object: (NaN, NaN)
    at new LatLng (<anonymous>:2760:9)
    at Object.unproject (<anonymous>:3060:10)
    at Object.pointToLatLng (<anonymous>:2901:26)
    at NewClass.unproject (<anonymous>:5381:27)
    at NewClass._getResizeMarkerPoint (<anonymous>:2805:20)
    at NewClass._createResizeMarker (<anonymous>:2795:29)
    at NewClass._initMarkers (<anonymous>:2462:8)
    at NewClass.addHooks (<anonymous>:2417:11)
    at NewClass.enable (<anonymous>:7112:8)
    at NewClass._enableLayerEdit (<anonymous>:4619:18)

Source is https://github.com/Leaflet/Leaflet.draw/blob/develop/src/edit/handler/Edit.Circle.js#L19 Restored shape does not have _radius property.

Real circle radius is stored in _mRadius property, so _radius perhaps is something other. (New-drawn circle has _radius property, that's why we can edit it)

Perhaps the issue came from difference between L.Circle and L.Geodesic.Circle implementations.

johnd0e commented 5 years ago

Just drawn circle can be edited without problems.

Correction: 'without exceptions'. Editing itself is not OK, as it lacks outer handler (to change radius).

modos189 commented 5 years ago

Perhaps the issue came from difference between L.Circle and L.Geodesic.Circle implementations.

Yes, I replaced in https://github.com/IITC-CE/ingress-intel-total-conversion/blob/256f9c53a866a254b40e40b1f766e58b4d2a89f4/plugins/draw-tools.user.js#L254

L.geodesicCircle to L.circle

And that solved problem. Exception does not happen, center of circle can be moved.

up: In original, geodesicCircle should be curved near Earth's poles, but this does not happen.

johnd0e commented 5 years ago

up: In original, geodesicCircle should be curved near Earth's poles, but this does not happen.

I have even more bad news: Using old draw-tools the GeodesicCircle is like this:

![image](https://user-images.githubusercontent.com/1838643/56789493-aba21a80-680a-11e9-9aa9-b4f698af9528.png)

But using our current draw-tools (with updated Leaflet.draw) the shape is completely wrong (ellipse).