简体   繁体   English

如何在OL3中获取图层或源的类型?

[英]How to get the type of layer or source in OL3?

I want to know how I can get the type of a layer and a source in ol3? 我想知道如何在ol3中获取图层类型和源代码?

Background: I have a map which the user can modify. 背景:我有一张用户可以修改的地图。 The user can (de)activate layer from different sources and I want to extract all the settings the user has made. 用户可以(de)激活来自不同来源的图层,并且我想要提取用户所做的所有设置。 Like the visible layer, the center point, resolution and more to rebuild the map later. 像可见图层,中心点,分辨率和更多以后重建地图。

At the moment I want to collect all the layers and it's sources, but I'm not able to get the layer type. 目前我想收集所有图层及其来源,但我无法获得图层类型。 So I don't know if it's a Tile or a Image, etc. 所以我不知道它是瓷砖还是图像等。

Unfortunately object.constructor.name is an empty string. 不幸的是,object.constructor.name是一个空字符串。 So any other ideas? 还有其他想法吗?

使用instanceof例如layer instanceof ol.layer.Tile

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

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