[GIS] Add KML file with associated PNG images as OpenLayers layer

kmlkmzpng

I have private sonar data in KMZ format, and can easily produce more. I understand that OpenLayers cannot use KMZ files, so my question is if it can handle the uncompressed KML file with all the PNG images. Since all geographic information is in the KML file it should work, right? I've tried with GML and vector layers but just haven't managed to make it show up yet…

My solution so far has been to use MapTiler, create tiles and then use a xyz layer. But I would rather use my KMZ if possible.

Best Answer

If you render raster data into map tiles you have to choose whether you want to create a Google Earth tiles (in Plate Carree) for displaying in KML/KMZ or Google Maps tiles (Mercator) for displaying in the web viewers such as OpenLayers, Google Maps, Leaflet, etc.

These uses two different map projections. Cartographically correct solution is to render two different tile sets with MapTiler (http://www.maptiler.com/) and host these separately.

In the MapTiler in the first screen you can make this choice, either "Mercator tiles" or "Google Earth".

enter image description here

I would recommend to go for two different datasets.

Technically, a hack which would display the Mercator tiles in Google Earth could be done as well - this could run for the deep-zoomed viewes - but if your data covers large regions (countries,states,continents) the differences between the map projections would already be visible as a north-south shift while zooming. See my documentation and source code in python at http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ if you are into this approach. Still this is a hack and proper solution is mentioned above - with two distinct tilesets.

Related Question