android-maps-utils icon indicating copy to clipboard operation
android-maps-utils copied to clipboard

GroundOverlay not put on map for KMZ-formatted bathymetric maps

Open OlavAa opened this issue 4 years ago • 3 comments

I'm working on a drone app for boats, and have implemented the KmlOverlay to let users add bathymetric maps to their base maps. This works fantastic with the exception of KMZ files that include ground overlays. These are simply not displayed. I cross my fingers and hope you can fix this.

The app users typically utilize the "Reefmaster" software to create the bathymetric maps, and then export them to KMZ for use in other applications like Google Earth.

In my app I simply add the layers to the map with these simple commands: layer = new KmlLayer(mMap, url, context, markerManager, polygonManager, polylineManager, groundOverlayManager, imageCache); layer.addLayerToMap();

I found a workaround: Modifying the structure of the kml within the kmz (explained below). Then everything works. The modification is however messy: It alters and invalidates the root structure of the kml. So I would like not to advise app users to do this (it is a last resort for my beta users right now). Please note: The original file imports perfectly into Google Earth, but KmlLayer fails to render the image. While the modyfied files fails to import in Google Earth, but now KmlLayer renders the image fine...

The root cause is related to how the KMZ from Reefmaster is structured.

The KMZ file from Reefmaster typically contains two files:

  • png image, if part of the map project
  • doc.kml

The Reefmaster application typically exports to a KMZ with a KML containing 4 <Document> tags.

  1. The styles
  2. The majour contours
  3. The minor contours
  4. The shoreline

If users in Reefmaster add a so called "Shaded relied", a 3D-like png is added to the project below contours of the bathymetric map for improved readability. In the exported KML file, the groundoverlay part is added within the first Document tag (among the styles). Collapsed like this:

kml .. @xmlns:http://www.opengis.net/kml/2.2 Document .. nameMyWater+ Style ..+ Style ..+ Style ..+ GroundOverlay ..+ Document .. nameMajor Contours + Placemark ..+ Placemark ..+ + Document .. nameMinor Contours + Placemark ..+ Placemark ..+ + Document .. nameShorelines + Placemark ..

The workaround I found is to cut out the ground overlay and put it above the first document tag. As explained, KmlLayer now works perfect. But the same file is not longer possible to import into Google Earth: ``kml .. @xmlns:http://www.opengis.net/kml/2.2 GroundOverlay ..+ Document .. nameMyWater+ Style ..+ Style ..+`

OlavAa avatar May 30 '20 10:05 OlavAa

I may have been a bit inaccurate in the description:

  • Using original KMZ file, the overlay is not rendered while the contours are
  • While using the modified KMZ file, both overlay and the contours are rendered

App screenshots should clearly show the differences. If needed I can provide sample kmz files in original and modified versions.

OriginalKmz ModifiedKmz

OlavAa avatar May 30 '20 13:05 OlavAa

Thanks for very clearly reporting this issue, @OlavAa and glad you were able to find a workaround. It's certainly not ideal though and the library should handle the KMZ file as-is (esp. with compatibility with Google Earth).

Unfortunately, I currently don't have the bandwidth to pick this issue up. However, given that KMZ was a community contribution (see #625), I'm adding the help wanted label here in case someone from the community wants to contribute.

arriolac avatar Jun 02 '20 18:06 arriolac

Thanks, Chris! I added a KMZ exported from the Reefmaster application, if anyone is able to contribute then test data is readily available. Please note: I am not allowed to attach KMZ files, so file extension is changed into ZIP. Please change file type back to KMZ when used for testing. ef3_original.zip

Sample imports successful into Google Earth, displaying png as ground overlay with contours drawn on top (tested). Using KmlOverlay, currently only contours are rendered.

OlavAa avatar Jun 03 '20 10:06 OlavAa

@OlavAa this should be fixed in #1166. I debugged and tested with your ef3_original.kmz file above.

jeffdgr8 avatar Mar 07 '23 04:03 jeffdgr8

Sorry for the delay. And awesome! I did not notice that the merge was blocked by a missing confirmation. So here we go!

Forked the main library, then made a brand new version of a depth map using Reefmaster in two versions: Regular isobath (Google Earth Vector map as Reefmaster calls it) and the problematic shaded relief.

First test before modification of both showed the expected behaviour, that the isobath is rendered as expected and that the ground overlay was not visible (only the KML lines visible).

Then I added the same modification of the addGroundOverlays function as in your fork:

addGroundOverlayToMap(groundOverlayUrl, groundOverlays, true); // addGroundOverlayToMap(groundOverlayUrl, getGroundOverlayMap(), true);

And, as you also found, the ground overlay is now visible. Test with isobath works as before, test of Shaded Relief variant now works also.

I notice two things using the altered code:

  1. Using the demo KML Layer Overlay for the test, the code never zooms in on the object when the shaded relief variant is used. Neither before, nor after the change. This I believe is caused by the code is not reading the bounds as provided by the overlay properly. For this I already have a fix in my own app, not really a concern.
  2. The shaded relief maps shows up with a different color palette than defined. So I did a check using the Google Earth Pro, and it actually behaves identically. This could be improved, but I can probably fix this as well in my own application.

Summary: The fix in #1166 is successful, and KMZ files are now rendered in the map utils library exactly as in Google Earth (polylines and polygons actually better than Google Earth that thickens the lines too much). This fix is totally accepted.

How do I add a status here to clearly state the issue is fixed so that this issue is no longer blocking a merge and I can get this fix into an upcoming update?

OlavAa avatar May 21 '23 08:05 OlavAa

In my view this issue is now fixed! Thanks!

OlavAa avatar May 21 '23 08:05 OlavAa

How do I add a status here to clearly state the issue is fixed so that this issue is no longer blocking a merge and I can get this fix into an upcoming update?

Thanks for confirming the fix @OlavAa. The PR https://github.com/googlemaps/android-maps-utils/pull/1166 is just pending review to be merged and released. Should be a quick one, with the one line changed @wangela.

jeffdgr8 avatar May 21 '23 15:05 jeffdgr8

Will reopen until the fix is merged

wangela avatar Aug 08 '23 00:08 wangela

:tada: This issue has been resolved in version 3.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

googlemaps-bot avatar Aug 08 '23 07:08 googlemaps-bot