Problem with openlayers and the properties of their instances

1

Can I create a property that is named "name" and add it to the instance I created from this layer?

var osm = new ol.layer.Tile({
    name: "pepe",
    source: new ol.source.OSM()
 })

What I want to do is differentiate this layer from another by that name. And so do search conditions. For example: If it's called Pepe, I want this layer.

I found something. Using console.log, the structure of this object to reach the name is like this:

osm.N.name

Is this the way?

    
asked by Pelayo 17.04.2018 в 10:04
source

1 answer

0

Solved. You have to use the following method:

.get('key')

Applied to my example it would be:

osm.get('name');
    
answered by 18.04.2018 в 10:00