0

I'm working with Google Maps API JavaScript Library. I am trying to display a Groundoverlay image on top of a KMZ layer. Whatever I try, the KMZ layer stays on top, blocking my Groundoverlay image.

I have already noticed that one cannot specify a zIndex for Groundoverlays. Any help will be very much appreciated. Below is the javascript code that illustrates the problem:

<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: {lat: 51.92123061150897, lng: 4.482456756591775}
});

var ctaLayer = new google.maps.KmlLayer({
url: 'http://bit.ly/1PjfdTp',
map: map, 
preserveViewport: true
});

var doctorbounds = {
north: 51.911766,
south: 51.909567,
east:  4.469100,
west:  4.466565
};

var doctorpicture = new google.maps.GroundOverlay(
'http://bit.ly/1mIHLPG',
doctorbounds);
doctorpicture.setMap(map);
}
</script>
Haroldus
  • 15
  • 4
  • Please provide a [Minimal, Complete, Tested and Readable example](http://stackoverflow.com/help/mcve) that demonstrates the issue. You may need to make a custom overlay that attaches to a higher map pane than the KmlLayer class uses. – geocodezip Jan 07 '16 at 19:29
  • Another thought: have you tried including the GroundOverlay in the KML? – geocodezip Jan 07 '16 at 19:30
  • Code is included, excuse me for any inconvenience. – Haroldus Jan 08 '16 at 19:21
  • I played around with your code, none of the usual suspects seem to work (putting the GroundOverlay in the kmz file, putting it in another KML file and changing the zIndex of the layers, controlling the order of loading). [Latest fiddle](http://jsfiddle.net/geocodezip/qd3e2o9m/5/), but nothing I tried seemed to work. zIndex _should_ work, according to the [documentation](https://developers.google.com/maps/documentation/javascript/reference#KmlLayerOptions). – geocodezip Jan 08 '16 at 22:24
  • Thanks for your attempt geocodezip. I have tried it myself a million times now, without any luck. The only thing I found - that seemed to work - was [this](http://plnkr.co/edit/Ef7b5AIroNinL2XuRBmZ?p=preview). This solution was proposed [earlier](http://stackoverflow.com/questions/30903703/geoxml3-groundoverlay-zindex), but just works in Plunker and not in my browser. I cannot display a KML Groundoverlay using the geoxml 3 parser, while using exactly the same code. I'm not sure if this would be a good solution anyway. – Haroldus Jan 10 '16 at 13:28
  • That seems strange to me, have you moved the KML to the same domain? geoxml3 is subject to the same domain restriction. – geocodezip Jan 10 '16 at 19:21
  • [Works for me on my server](http://www.geocodezip.com/geoxml3_test/v3_geoxml3_GroundOverlayOverPolygon.html). – geocodezip Jan 10 '16 at 19:28
  • [And it works for me with your polygon/GroundOverlay (moved to my server)](http://www.geocodezip.com/geoxml3_test/v3_geoxml3_GroundOverlayOverPolygonB.html) – geocodezip Jan 10 '16 at 19:34

1 Answers1

0

It can be done with geoxml3 as described in the answer to this question (Geoxml3 groundOverlay zIndex) by Vadim Gremyachev.

(note that all the KML files need to be on the same domain to work with geoxml3 or accessed through a proxy).

working link

Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245