3
votes

Does Google Maps support KML regions like Google Earth does?

Google gives a nice description/tutorial of regions here:

https://developers.google.com/kml/documentation/regions

which mentions Google Earth specifically, but not Google Maps.

According to https://developers.google.com/kml/documentation/kmlelementsinmaps Google Maps DOES support KML regions, but https://developers.google.com/kml/documentation/mapsSupport doesn't mention them explicitly.

Zoom levels in kml files on google maps is also ambigious on the issue.

I created my own test KML file (stolen almost verbatim from google):

<?xml version="1.0" encoding="UTF-8"?>  
<kml xmlns="http://www.opengis.net/kml/2.2">  
  <Document>  
    <name>Flat Region</name>  
    <Region>  
      <LatLonAltBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonAltBox>  
      <Lod>  
        <minLodPixels>128</minLodPixels>  
      </Lod>  
    </Region>  
    <GroundOverlay>  
      <name>Mountain View DOQQ</name>  
      <Icon>  
        <href>http://data.bcinfo3.barrycarter.info/graphpaper.gif</href>  
      </Icon>  
      <LatLonBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonBox>  
    </GroundOverlay>  
  </Document>  
</kml>  

You can see it here:

http://test.bcinfo3.barrycarter.info/bc-image-overlay.pl?url=regiontest.kml&center=37.425,-122.085&zoom=15

As you zoom out, the image remains visible (albeit as a white square) even when it's only a few pixels on each side.

Does the "minLodPixels" setting of 128 in the KML file mean it should stop being visible once it takes up fewer than 128 pixels?

If so, would this prove Google Maps does NOT support KML regions?

Or am I misunderstanding something?

1

1 Answers

0
votes

I can't give you a completed solution but I tried to avoid overcrowding of my points using Regions in maps about a year ago (asked a similar question on SO) and it was my understanding that KmlLayer would not recognize regions and instead just load everything. The only reference I can find to this are forum posts though e.g.: http://code.google.com/p/gmaps-api-issues/issues/detail?id=3142

That said it was my understanding at the time that this could be achieved by using the API to add the overlays and regions in javascript - I just looked and I can not find a good example of this (or any example at all).

It does seem to me though that it should be pretty easy to write a custom Overlay and override the draw function to take account of the size of the overlay before showing / hiding as the map is zoomed: https://developers.google.com/maps/documentation/javascript/overlays#Drawing

Which is the path I intend on taking when we implement some of the features we need around it - but does not solve having this implemented directly from the KML. What is interesting is you link to the documentation indicating it is supported.