在功能使用example,有2个属性称为和rainfall
。OpenLayer特性中属性“人口”的用途是什么?
...
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0, 0]),
name: 'Null Island',
population: 4000,
rainfall: 500
});
...
这是什么意思?我四处搜寻,没有找到任何信息。
在功能使用example,有2个属性称为和rainfall
。OpenLayer特性中属性“人口”的用途是什么?
...
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0, 0]),
name: 'Null Island',
population: 4000,
rainfall: 500
});
...
这是什么意思?我四处搜寻,没有找到任何信息。
这是一个向通用属性添加通用属性的示例,您可以在其他位置使用该通用属性。这个例子并没有让它变得非常明显。在该示例中,您可以添加另一个名为'numberOfDonkeys'的属性,值为20,然后可以在触发弹出窗口的点击事件中使用该属性。敌我的例子,我可以改变功能是这个。
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0, 0]),
name: 'Null Island',
population: 4000,
rainfall: 500,
numberOfDonkeys: 20
});
并将地图点击事件更改为此。
// display popup on click
map.on('click', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function(feature) {
return feature;
});
if (feature) {
var coordinates = feature.getGeometry().getCoordinates();
popup.setPosition(coordinates);
$(element).popover({
'placement': 'top',
'html': true,
'content': feature.get('name') + ' Pop: ' + feature.get('population') + ' Donkeys: ' + feature.get('numberOfDonkeys')
});
$(element).popover('show');
} else {
$(element).popover('destroy');
}
});
而且您会在弹出窗口中看到Population和numberOfDonkeys属性。
的jsfiddle示例 - https://jsfiddle.net/z7adr7q0/1/
最终你不需要这些属性在所有的,你可以摆脱他们,他们是你想在这个重用,在那里你能放属性只是一个例子办法。
这并不意味着什么。空岛是定义了一些属性的虚构特征,就是这样。
你确定吗?你从哪里得到这些信息? – panoet
@panoet我住在那里,我可以确认我们不是4000 –