Labeling Polygons #1087
Replies: 4 comments 5 replies
-
Hi there, Hope this was somewhat informative :) |
Beta Was this translation helpful? Give feedback.
-
Not entirely sure what the main issue is (if you calculate the center as a one off), you know the point to place the label. So it may help to explain what is meant by "impaired" ? Are we talking slowdowns or difficulty or something else ? |
Beta Was this translation helpful? Give feedback.
-
Here is an example I did pushing a fair amount of polys and some collision detecting labelling. https://www.youtube.com/watch?v=KTjlWrcRE-Q |
Beta Was this translation helpful? Give feedback.
-
See if this is any help...(note, everything is painted on a single customPainter canvas which I assume could have a transparent background if wanted)
None of them are widgets, they are are TextPainter elements painted onto a canvas. If you go down this route, it's worth bearing in mind text layout is an expensive operation, so do it once and then cache it, and try to reuse as much as possible (even for other labels). Actually the same with polygons/polylines. If drawing on a canvas, it's good to batch up all polygons into one super path (Path.addPath/addPolygon) and then do one draw call. So if you have 200 polygons (that are all the same style!), draw them in one go. There are some flaws with this, depending on how much of it is on screen. Same with the labels, which is why it's sometimes difficult to have one well optimised but general solution. Each case feels like it's a bit different.
Some of this though is optimised because its using Tiles which each only cover a certain area, so there's no need to calculate if a poly is on the display. I think the trickier problem is when you have a mass of polys and you have no real segregation into tiles/areas that you know are in view, but I think that's probably achievable as a first time optimisation if there's a large set of polys, but again it's possibly tricky to have one generic fits all size that could be incorporated into flutter_map. |
Beta Was this translation helpful? Give feedback.
-
Hello fellas, I'd like to know if anyone has ever needed to add a simple label inside a polygon (for identification purposes) using flutter_map, as is customary for any GIS application who deals with features like Polygons.
We added some polygons using PolygonLayerOptions which uses a List to show on the map. The Polygon class doesn't have an attribute like 'label', 'text' or anything like that, which would be very useful.
Our application has several polygon attributes in its internal classes like centroid, extension and others, however manually adding markers or things like that doesn't seem efficient to me. We didn't actually find any way to add labels to the vector layers of flutter_maps (Polygons, Lines etc.).
Thanks in advance for any suggestions
Beta Was this translation helpful? Give feedback.
All reactions