Closed Athanasius closed 5 years ago
May be better in layer-count?
Layer Count operates only on existing fields, not DrawTools polygons, doesn't it ?
I'll investigate the best mechanism. I'm specifically thinking of this sequence:
Rather than the total area by all draw polygons (which also might not take fly links into account).
So, in theory, this just means hooking into when a polygon has just been completed, or an edit on it finished, to display the area. I may well look at how Layer Count does its display for inspiration, although plugin-order can sometimes mean that displays in an inconvenient location (I'll see about opening another Issue about that).
I'll work towards this for now, just to see how well it works, then could consider applying the same code to Layer Count as well, but remember that Layer Count is on existing fields, not on DrawTools polygons.
Layer Count operates only on existing fields, not DrawTools polygons, doesn't it ?
Drawn polygons too.
but remember that Layer Count is on existing fields, not on DrawTools polygons.
You better try
It would help if Layer Count was actually working (Firefox and Linux), which prevented me making sure. I'll go file an issue with the error.
@Athanasius Make sure with test build
With Layer Count working on the latest test build I can see that it does indeed also work on Polygons, so adding area count to that output would certainly be doable and useful to some.
But the extra clicks of drawing, using layer count, edit polygon, use layer count again just seems awkward, so I'll see about either an option to Layer Count to have a permanent display, or the separate plugin as well.
an option to Layer Count to have a permanent display
Explain how it might work
or the separate plugin
map.on(L.Draw.Event.CREATED, function (e) {
if (e.layerType === 'polygon') {
// calculate area of e.layer and show it in any way (tooltip, sidebar, ...)
}
});
https://github.com/Athanasius/iitc-ce_ingress-intel-total-conversion/tree/layer-count-area
This version, as per your suggestion, ends up putting the (total for live fields) area on the usual layer count output strings. I'll see if this suits my needs, and if needs be see about additions to DrawTools to show this as a single polygon is edited.
It's against latest test-builds branch. Let me know if coding/commenting style or anything else needs addressing.
This will probably be best implemented as a direct part of DrawTools.
When trying to judge the exact portals to use for pre-planned fields it would be good to know the area covered by a given Polygon (easier to implement than "click on map, check for any triangle there made by DrawTools lines..."). Perhaps a popup/hover when editing a Polygon?
Keep in mind that for larger polygons proper "on the surface of a sphere" calculations will be necessary, and it's easiest to just do this anyway given it would be working off of Lat/Long co-ordinates of the corners.
If I find time I'll investigate and may provide a PR.