views:

442

answers:

1

I have a problem with the Google Maps API only allowing 1000 features per map.

In a database, I keep records of areas. Each area has associated with it a heap of KML polygon information, stored as an XML string. Each area is made up of one or more polygons.

Given some user input, a handful of these areas are combined into one <Placemark>. I get their combined geometry by wrapping the concatenated polygon information in a <MultiGeometry> tag.

<Placemark>
    <name>My combined area</name>
    <MultiGeometry>
        <Polygon> (area 1 info) </Polygon>
        <Polygon> (area 2 info) </Polygon>
        <Polygon> (area 2 info) </Polygon>
        <Polygon> (area 3 info) </Polygon>
    </MultiGeometry>
</Placemark>

The problem is that many of these areas are highly complex, and hence, any given Placemark could have over 100 polygons which very quickly pushes me of the limit of 1000 per document.

Now, given that the combined areas mostly form a single continuous area, there are a lot of lines and polygons on the inside of the continuous area which are quite useless. Is it possible to loop through the Polygons and merge them into one (or at least, fewer) polygons?