Help with massive polygons

Hello, I'm making an app that involves the user pressing on a part of a map to zoom in to a specific county of Massachusetts in the US. I decided that using polygons to represent the counties was the way to approach this, since I can simply make it so that if the user presses on a county, which has an invisible polygon over it, the map pans to the polygon. However, I've found that the array for polygon borders of counties are extremely large to the point that I suspect the reason my app is crashing is because it simply can't process the amount. I would like some advice on solving this problem, or perhaps an alternative way to solve my original problem without using polygons.

Below is the csv file that contains the polygon coordinates.

us-county-boundaries (2).csv (860.1 KB)

Welcome @John_Seungjin_Oh to our community!

How many sides does your polygon consist of? Maybe I can help you with the bug.

There are 14 polygons that should have anywhere from about 15,000 to more than 37,000 sides, as it can be seen in the file that I linked.

Is this something you can use? (Data was last updated 10 years ago)

I took the json from one of the files and pasted it into a featurecollection.

You can give each county it's own color



you can do things when you for instance click on a featurecollection

Welcome John.

  1. Peter pointed out, the way to display the counties is to use a FeatureCollection
  2. The csv file you attached has issues loading and is not a simple file showing only the polygon points. It contains extraneous information. . Find a Massachusetts json file with the counties and use a FeatureCollection to load them.
  3. Here is a very basic example using Texas counties showing all the Blocks.


The TexasCounties json file is 176 kb. OSM has difficulty rendering files much larger than this sometimes
4. An issue you have is using LOTS of individual detailed polygons. OpenStreetMaps has difficulty rendering them. Using an file with fewer point should work for you. :slight_smile:
5. Be patient when loading the FeatureCollection, it may take a minute or two.

I hope this helps you create your app.

You might need different polygon files depending on your zoom level:

  • course polygons for big areas
  • finer polygons for smaller regions with fewer corners