更改了功能的字体并获得 "Assertion failed: Expected feature to be removed from index"
Changed font of feature and got "Assertion failed: Expected feature to be removed from index"
我用 openlayers 绘制了一个往返图。
不同的点有这样的风格:
new ol.style.Style({
image: new ol.style.Circle({
radius: 2,
fill: new ol.style.Fill({
color: 'rgba(1,0,0,0)'
})
}),
text: new ol.style.Text({
font: 'normal 600 12px Calibri, sans-serif',
text: feature.get('TEXT'),
offsetX: 0,
offsetY: +12,
fill: new ol.style.Fill({
color: 'rgba(1,0,0,0)'
})
})
})
我想为特定事件修改字体(导出 png),因此对于每个功能我都在更改字体
for (var i = 0; i < vector_service_port.getSource().getFeatures().length; i++) {
vector_service_port.getSource().getFeatures()[i].setStyle(new ol.style.Style({
text: new ol.style.Text({
font: 'normal 600 14px Calibri, sans-serif'
})
}));
}
但是我遇到了错误
Uncaught AssertionError: Assertion failed: Expected feature to be
removed from index
我怎样才能绕过它?
我会做类似的事情:
var features = vector_service_port.getSource().getFeatures();
features.forEach(function(feature){
feature.getStyle().getText().setFont('your desired font');
});
我用 openlayers 绘制了一个往返图。 不同的点有这样的风格:
new ol.style.Style({
image: new ol.style.Circle({
radius: 2,
fill: new ol.style.Fill({
color: 'rgba(1,0,0,0)'
})
}),
text: new ol.style.Text({
font: 'normal 600 12px Calibri, sans-serif',
text: feature.get('TEXT'),
offsetX: 0,
offsetY: +12,
fill: new ol.style.Fill({
color: 'rgba(1,0,0,0)'
})
})
})
我想为特定事件修改字体(导出 png),因此对于每个功能我都在更改字体
for (var i = 0; i < vector_service_port.getSource().getFeatures().length; i++) {
vector_service_port.getSource().getFeatures()[i].setStyle(new ol.style.Style({
text: new ol.style.Text({
font: 'normal 600 14px Calibri, sans-serif'
})
}));
}
但是我遇到了错误
Uncaught AssertionError: Assertion failed: Expected feature to be removed from index
我怎样才能绕过它?
我会做类似的事情:
var features = vector_service_port.getSource().getFeatures();
features.forEach(function(feature){
feature.getStyle().getText().setFont('your desired font');
});