1

I have 8000 polygons that I need to show on Google maps (certain US Zip/Postal codes -- not all of them). I have a "root" KML file that contains 10 network links that divide these zip codes up by region. In those region network links, I have more network links that divide these up by state with an average of about ~300 polygons per file. Below is an example of my KML files (shortened for example):

Root.kml:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>regions</name>
    <NetworkLink>
      <Link>
        <href>https://url/region0.kml</href>
        <viewRefreshMode>onRegion</viewRefreshMode>
      </Link>
    </NetworkLink>
    <NetworkLink>
      <Link>
        <href>https://url/region1.kml</href>
        <viewRefreshMode>onRegion</viewRefreshMode>
      </Link>
    </NetworkLink>
    <!-- additional Network Link regions -->
  </Document>
</kml>

region0.kml:

?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>region0</name>
    <NetworkLink>
      <Region>
        <LatLonAltBox>
          <north>36.244860000000003</north>
          <south>31.542739999999998</south>
          <east>-109.49429000000001</east>
          <west>-114.66689</west>
        </LatLonAltBox>
        <Lod>
          <minLodPixels>128</minLodPixels>
          <maxLodPixels>1024</maxLodPixels>
          <minFadeExtent>128</minFadeExtent>
          <maxFadeExtent>512</maxFadeExtent>
        </Lod>
      </Region>
      <Link>
        <href>https://url/US-AZ.kml</href>
        <viewRefreshMode>onRegion</viewRefreshMode>
      </Link>
    </NetworkLink>
    <!-- additional State KMLs for this region -->
  </Document>
</kml>

US-AZ.kml:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>US-AZ</name>
    <Region>
      <LatLonAltBox>
        <north>36.244860000000003</north>
        <south>31.542739999999998</south>
        <east>-109.49429000000001</east>
        <west>-114.66689</west>
      </LatLonAltBox>
      <Lod>
        <minLodPixels>128</minLodPixels>
        <maxLodPixels>1024</maxLodPixels>
        <minFadeExtent>128</minFadeExtent>
        <maxFadeExtent>512</maxFadeExtent>
      </Lod>
    </Region>
    <Placemark>
      <name>85208</name>
      <Polygon>
        <outerBoundaryIs>
          <LinearRing>
            <coordinates>-111.68398999999999,33.393230000000003
-111.58019,33.393160000000002
-111.58078999999999,33.404260000000001
-111.58089,33.404260000000001
-111.58078999999999,33.407719999999998
-111.59789000000001,33.407760000000003
-111.59799,33.411209999999997
-111.58909,33.411250000000003
-111.58929000000001,33.414940000000001
...
            </coordinates>
          </LinearRing>
        </outerBoundaryIs>
      </Polygon>
    </Placemark>
    <!-- additional Placemarks -->
  </Document>
</kml>

It seems to work fine for the first region and the first state in that region (this example is US-AZ Arizona), but ignores all other regions and states. So about ~1000 polygons get rendered, but none of the other 8000 polygons get rendered.

When loading the KML in Google Earth, each of the state KML files work fine individually.

I followed the Google Keyhole examples for NetworkLink and Regions, but it doesn't seem to matter what I do that any of the other regions and network links will render.

Any ideas or a better way to show 8000 polygons using Google maps that I might be missing (and doesn't take a very long time to display on the map)?

Sean
  • 2,496
  • 7
  • 32
  • 60
  • KmlLayer has [restrictions/limitations](https://developers.google.com/maps/documentation/javascript/kmllayer#restrictions). If you need to show all that data at one time, you will probably need to make your own tile server.. – geocodezip Sep 11 '19 at 21:28
  • All the requirements are met except for 10 network links. Is this 10 network links per kml file or 10 through all the linked kml files? If the limitation is speaking about "document-wide" as a , then I only have 200 to 800 polygons/features per kml file (at the lowest layer). – Sean Sep 11 '19 at 22:39
  • Perhaps it is the last restriction then: Number of KML layers – geocodezip Sep 11 '19 at 23:09
  • 1
    Google Maps will follow a maximum of 10 network links, doesn't matter if they are all in the top level file, or cascaded in sub files. – Christiaan Adams Sep 12 '19 at 22:58

1 Answers1

0

Thanks to @Christiann Adams and @geocodezip to setting me straight.

For anyone else that is having this issue, you can only have 10 network links TOTAL through all files (as mentioned in the comments above).

How I got around it was having multiple KML layers, with no more than 10 network links per file. This seems to work for me.

Hope it helps someone else.

Sean
  • 2,496
  • 7
  • 32
  • 60