Search code examples
openlayerskmlkmz

Why doesn't the OL KMZ example work with my file?


I need to view KMZ files with OpenLayers.

The KMZ I am working with is on GitHub.

The structure of the KMZ (zip) file is:

wash/
    files/
        wash-dc.png
    wash-dc.kml

wash-dc.png is:

dc

The content of the kml file is:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Folder>
    <GroundOverlay>
      <Icon>
        <href>files/wash-dc.png</href>
      </Icon>
      <LatLonBox>
        <north>38.9098629826801456</north>
        <south>38.8880073821501711</south>
        <east>-77.0497762322933539</east>
        <west>-77.0120905091252439</west>
        <rotation>0</rotation>
      </LatLonBox>
    </GroundOverlay>
  </Folder>
</kml>

If I double click on the kmz file, the Google Earth App I have installed on my local machine launches and successfully displays the KMZ:

google earth

I have found the OpenLayers example on OpenLayers website.

However, when I try dropping my KMZ file on it, it does not work. There are no errors in the console. The view in DC is:

ol example

How would this sample code need to change so my KMZ can be viewed? Or, is there something wrong with my KMZ?


Solution

  • At present, the KML parser in OpenLayers doesn't support GroundOverlays.

    See (old, but still relevant):

    source code for KML