简体   繁体   English

Openlayers 3 动态刻度 - 如何打开和关闭它?

[英]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.我希望能够动态地打开和关闭刻度,但刻度文档没有未设置,只有setMap()函数。 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?当我想要它消失时,我是否有一个辅助的空未使用地图和setMap() ,然后在切换时回到我的主地图?

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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