简体   繁体   中英

Openlayers 3 dynamic graticule - how to switch it on and off?

I would like to be able to toggle the graticule on and off dynamically, but the graticule documentation doesn't have an unset, just a setMap() function. How do I dynamically add/remove a graticule to the map?

Do I have a secondary empty unused map and setMap() to that when I want it to go away, then back to my main map on toggle?

According to comments, to record:

var graticule = new ol.Graticule({
    map: map //Reference to an ol.Map object
});

And later, to remove from the map:

graticule.setMap(null);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM