在 openLayers 6.x 我如何访问变量?
In openLayers 6.x how i can access the variables?
我的地理区域变量声明如下
var geozonas = new VectorLayer({
source: new VectorSource({
url:'https://geo.anantara.cl/maps/json/geozone2.json',
format: new GeoJSON()
})
});
我想访问这段代码中那个变量 geozonas 的 features,我该怎么做?
geolocation.on('change:position', function() {
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ?
new Point(coordinates) : null);
view.setCenter(coordinates);
});
我了解到框架设计避免了全局变量的使用,那么如何引用呢?
提前致谢
巴勃罗
迈克指出的是正确的,如果为了访问这些功能,我必须以某种方式意识到它已全部加载,这个主题已经在常见问题解答中讨论过,并且从那里访问该层。
我的地理区域变量声明如下
var geozonas = new VectorLayer({
source: new VectorSource({
url:'https://geo.anantara.cl/maps/json/geozone2.json',
format: new GeoJSON()
})
});
我想访问这段代码中那个变量 geozonas 的 features,我该怎么做?
geolocation.on('change:position', function() {
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ?
new Point(coordinates) : null);
view.setCenter(coordinates);
});
我了解到框架设计避免了全局变量的使用,那么如何引用呢?
提前致谢 巴勃罗
迈克指出的是正确的,如果为了访问这些功能,我必须以某种方式意识到它已全部加载,这个主题已经在常见问题解答中讨论过,并且从那里访问该层。