Search code examples
google-mapskml

Hiding placemarks in KML used to center and zoom a map


I have a embedded map on my site in which I display various location based on the user's search results. In some cases we do not have location data and instead display a screen overlay indicating this. I additionally set a couple of placemarks to force the map to zoom and center on a specific region (the default if there is no location data being the full zoom out, which is kind of ugly).

My problem is I want to hide these placemarks, as otherwise they appear to indicate there are locations available and none of the following has worked:

  1. the visibility flag on elements seems to only be supported in google earth
  2. a custom transparent png specified as the Placemark Icon href does not load, and I get the default blue pin.
  3. I tried creating a region on the folder which encompasses the placemarks and setting a LOD which should disable it, but this appears to not do anything at all (KML below).

I believe I am missing a simple way to accomplish this, but a nudge would be helpful. Here is the KML using regions:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <ScreenOverlay>
      <Icon>
        <href>URL/mapDisclaimer.png</href>
      </Icon>
      <overlayXY x="0.5" xunits="fraction" y="0.5" yunits="fraction" />
      <screenXY x="0.5" xunits="fraction" y="0.5" yunits="fraction" />
      <size x="0" xunits="pixels" y="0" yunits="pixels" />
    </ScreenOverlay>
    <Folder>
      <name>PlaceHolderFolder</name>
      <Style id="placeholderStyle">
        <IconStyle>
          <Icon>
            <href>URL/transparentBlock.png</href>
          </Icon>
        </IconStyle>
      </Style>
      <Region>
        <LatLonAltBox>
          <north>79</north>
          <south>59</south>
          <east>-102</east>
          <west>-137</west>
        </LatLonAltBox>
        <Lod>
          <maxLodPixels>20</maxLodPixels>
        </Lod>
      </Region>
      <Placemark>
        <styleUrl>#placeholderStyle</styleUrl>
        <Point>
          <coordinates>-136.582031,69.16256</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <styleUrl>#placeholderStyle</styleUrl>
        <Point>
          <coordinates>-110.566406,78.560486</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <styleUrl>#placeholderStyle</styleUrl>
        <Point>
          <coordinates>-102.128906,59.977005</coordinates>
        </Point>
      </Placemark>
    </Folder>
  </Document>
</kml>

Solution

  • The transparent PNG should work, but you must move the <Style/>-element out of <Folder/> and make it a child of <Document/>