admin管理员组文章数量:1405584
I have a reset button that I want to reset the map (including removing overlays) when clicked.
I've been reading around and apparently the way you remove KML overlays is by;
Declaring your kml variable as a global variable
var ctaLayer = new google.maps.KmlLayer(null);
These are the lines that cause the kml file to overlay on google maps
var ctaLayer = new google.maps.KmlLayer(kmlFile);
ctaLayer.setMap(map);
And then call setMap(null) to remove the overlay.
ctaLayer.setMap(null);
However, this does not seem to be working. I don't get any errors so I'm guessing I'm missing something? I'd appreciate any advice on getting this to work.
I have a reset button that I want to reset the map (including removing overlays) when clicked.
I've been reading around and apparently the way you remove KML overlays is by;
Declaring your kml variable as a global variable
var ctaLayer = new google.maps.KmlLayer(null);
These are the lines that cause the kml file to overlay on google maps
var ctaLayer = new google.maps.KmlLayer(kmlFile);
ctaLayer.setMap(map);
And then call setMap(null) to remove the overlay.
ctaLayer.setMap(null);
However, this does not seem to be working. I don't get any errors so I'm guessing I'm missing something? I'd appreciate any advice on getting this to work.
Share Improve this question edited Jan 4, 2021 at 10:55 Ayoub Touba 3,0173 gold badges14 silver badges29 bronze badges asked Aug 13, 2012 at 1:35 MattMatt 1,5902 gold badges20 silver badges45 bronze badges 1- layer.setMap(null) is correct, so you must be doing something else wrong. Please post code. – ScottE Commented Aug 13, 2012 at 2:17
1 Answer
Reset to default 4Remove the var from in front of the second var ctaLayer (the one that makes it local to the function).
本文标签: javascriptRemoving KML overlay from Google MapsStack Overflow
版权声明:本文标题:javascript - Removing KML overlay from Google Maps - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744866492a2629375.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论