Can't Re-Add Polygons in Android
See original GitHub issueHi,
I seem to have hit a problem that only exists in Android. If I end up using addPolygon
on a polygon that was previously added (after removing), the app crashes. I seem to have narrowed down where it “dies”.
addPolygon(shape: Polygon) {
shape.loadPoints(); // last time things were good
shape.android = this.gMap.addPolygon(shape.android); // dies during this
this._shapes.push(shape);
}
I tried playing around with some different things, such as making it use reloadPoints
instead of loadPoints
on repeats, but that didn’t seem to work.
I think I may try playing with visibility instead, for cases where I think there may be a chance that a shape would get re-added. But I figure this is worth bringing up. I’m guessing something similar would apply to polylines. Not sure about circles or anything else.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Adding holes to a polygon removes it's fill color - Stack Overflow
I created a Polygon that fills an entire Google Map. After I add a couple of holes, the map works fine. The map...
Read more >Shapes | Maps SDK for Android | Google Developers
You can add a Polygon to the map in the same way as you add a Polyline . First create a PolygonOptions object...
Read more >Create travel routes or areas of interest - Google Earth Help
Draw a path or polygon · Open Google Earth. · Go to a place on the map. · Above the map, click Add...
Read more >Add a feature—Collector for ArcGIS (Classic)
Collector adds (collects) features while you work in the field. ... For details on working with lines and polygons, see Draw a shape....
Read more >How can I fix my complex Polygons so they show correctly in ...
Polygons are rendered in Google Maps API using Canvas, which uses a zero-winding fill rule. To show a hole, you'll need to define...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is caused since the
android
property is changed from PolygonOptions (in the constructor) to Polygon (after loading the points - adding to map). A simple solution will be to keep theandroid
property the same and add another property for the existing polygon (for removal).As a workaround I simply recreated the polygon every time I needed to add it again.
It would be nice if this worked the same as google maps web api where it’s fine to re-add