question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't Re-Add Polygons in Android

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SBD580commented, Jun 15, 2017

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 the android 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.

0reactions
DanLatimercommented, Aug 3, 2018

It would be nice if this worked the same as google maps web api where it’s fine to re-add

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found