Need help with geo.json: Why are there jumping polygon-lines on the map?

Help! :pray: Tried many things to get this geo.json file to work:

  • Found/corrected many minor errors in code using VSCode
  • Hand-selected coordinates for a few countries
  • Minimized total coordinates for big countries (decreasing each from 5,000 to ~1,000 or less)
  • Friend used Python to check every first & last coordinate pairs to be sure they matched.
  • Used GeoJSONLint and found issue with “right-hand-rule" used Mapster "right-hand-rule-geojson-fixer" to correct, but Mapster added new issues...
  • Used regular expressions on VSCode to remove all spaces & new-lines, then reformatted with newlines only for each country (more readable format / takes less memory)

:pleading_face: :hourglass_flowing_sand:
.... still haven't figured out this issue with horizontal/vertical polygon-lines jumping all over while moving map around on phone (AI companion). :thinking: What could be causing this? :question:

:warning: Error 3404 sometimes shows upon connecting AI companion to phone:

"Error 3404: Parse error attempting to create Polygon: Value of type java.lang.String cannot be converted to JSONArray."

Attaching screenshot of map (random lines change every time when even barely moving on map).
Map screenshot: https://imgur.com/LxZA3kV

Attaching geo.json file in case any one else can find an error in it or test if it works on their app maps.
countries3_geo.json (229.4 KB)

Thanks for the help!!

I suspect the issue is the OSM server you link to while using the Map control cannot
handle the 229 kb json and the resulting polygons fast enough to refresh. I see the same issue with your map using your geojson. While the geojson loads and the FeatureCollection renders apparently fine on the Designer; it does not work well using Companion.nor building the apk. I also tried this using the code.app…server with the same result.

I suspect you need to further reduce the size of your geojson. I ran into similar issues with a large file…I think I had to get it below about 200 kb to work (but I actually do not remember).

This behavior might be temporary. OSM servers are usually very busy on weekends.

At the present time I get this stable FeatureCollection using

NandSAmerica.json (132.7 KB) (which was made at https://geojson-maps.ash.ms/ ) and works fine on the emulator…

Try your file again later and it might not be jumpy. The smaller file for North and South America works fine.

– Steve

Thanks for the quick response! The geo.json size was shrunk from over 200kb to under 100kb & the issue still persists.

Another potential problem with the first file, was that there were many intersecting polygons (intersections found using Mapshaper). This was fixed using vectorRocks to manually move all the intersecting coordinates so there are no longer any polygons overlapping.

Even with these corrections, the file is still is not working properly on the map (shows jumping horizontal/vertical lines). Why else could this be happening? Any ideas to test please! Thank you!!

Corrected/Smaller geo.json file:
countries6_geo.json (92.7 KB)

:bulb: Updates: :bulb:
The lines appear to be countries stretching to multiple globes. If you keep dragging the map, you’ll see multiple copies of the same Earth. So, some coordinates are going to the wrong copy of Russia, for example. Therefore, Russia stretches across the visible map.

Looks like this is a common Leaflet issue, but can we fix this from our side, or is it something that MIT needs to fix on app inventor? https://github.com/Leaflet/Leaflet/issues/82

Another idea… is there a way for us to set boundaries on the map so that there aren’t copies of Earth? In the ai2 docs, found a property called “BoundingBox” - is this what is needed?

Searched for all latitudes past 180/-180. and all longitudes past 90/-90 and changed to 179.99 or 89.99 to keep within single-map boundaries. Still doesn’t work.

  • I tested the countries6. Yes, still the same issue. Did YOU test the json file I posted? That json works fine.

This leads me to believe your countriies6 file is corrupted.

Regarding a potential Leaflet issue, that thread ended indicating the issue is fixed " I removed LatLng wrapping/clamping by default alltogether (there’s now an explicit LatLng wrap method for this). So all similar problems should be solved now in theory."

If the observed behavior is a Leaflet issue; MIT can not ameliorate it. MIT has no relation to Leaflet.

Again, the issue may be the inability of the donated OSM server to handle the number of polygons or ill-formed polygons in your file.

@codo Please edit your question and add screenshots directly into your post rather than linking to an external site. Thank you.

add.screenshot

Taifun

This issue occurs with any geo.json tested. Also created a test to check 200 different geo.json files all with the same result, though it was not noticeable at first… the test helped to discover that this happens with every polygon when zoom/panned to a certain edge of the map. It’s just more noticeable with a full-world of polygons because the map-view-edges will constantly hit polygons.

These features (pictured below) show that perhaps this issue was attempted to be solved (or thought to be solved). But there’s no guide on things such as using the maps bounding box & polygon centroid blocks. It’s not clear which blocks we can connect and what exactly they will do.
Screen Shot 2020-03-31 at 6.15.06 PM Screen Shot 2020-03-31 at 6.15.47 PM Screen Shot 2020-03-31 at 6.19.14 PM

For now a buggy-workaround will be used, but will continue to work on this problem (it’s very fun learning about maps!). The workaround for now is to have all polygons’ fill-colors = transparent (not ideal) - this way the user doesn’t see so much jumpiness on the screen & countries can be clicked, but about 1/10 times when zoomed/panned, the user might click on an invisible stretched line which will give the wrong country.

Another workaround attempted was a static map in a horizontal scroll, but this makes the map sizing bug-out, and crashes both the app/AI-companion & the MIT AppInventor website.

When the map bounds = set to match edges of a rectangle at max North, West, South, East points, the viewable map is zoomed out to see the entire world & the lines issues does not exist until the map is zoomed/panned. This gives an idea that if theres a way to refresh the polygons and bounds during each drag/zoom, then perhaps the line issue wouldn’t exist.

Thanks! Newly learning to use these helpful forums.

Solved half of this issue so far. No more jumping lines by setting polygons outside the current-bounds to be not visible… but need to also find a way to keep user from being able to zoom/pan further than a single copy of the world. Have some ideas on how to code this part, but it’s a lot of code…

Has anyone accomplished setting max bounds so that a user can not see repeating worlds?

Dear Friends,
Any progress on this bug?
I've seen @ewpatton u were looking into it some time ago...