Answer the question
In order to leave comments, you need to log in
Is it possible to change layer on Google Maps on click?
Hello!
- There is a KML file, it has a lot of shapes. Consists of 2 layers.
- There is a page on which it is displayed.
Structure of KML:
1st layer - one big object.
2nd layer - many small objects (located inside the larger one, which lies in the 1st layer).
By clicking within the boundaries of the larger layer, you need to hide it and display only the 2nd layer.
Question:
Is it possible to implement this? If so, please provide a link to an example or documentation.
PS. I've searched the GoogleMaps documentation and haven't found anything yet.
Answer the question
In order to leave comments, you need to log in
/*------Добавить слой--------------------------------------------------*/
var layerMain = new google.maps.KmlLayer({
url: 'http://site.com/gmaps/2_0/layer_main.kml',
map: map
});
var layerSecond = new google.maps.KmlLayer({
url: 'http://site.com/gmaps/2_0/layer_second.kml',
map: map
});
/*------Действия по клику--------------------------------------------------*/
layerMain.addListener('click', function(event) {
console.log('click');
console.log('layer was removed');
layerMain.setMap(null);
map.setZoom(11);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question