【发布时间】:2017-01-17 03:55:06
【问题描述】:
这个例子展示了如何使用 postcompose 和 vectorContext 为特征设置动画:
http://openlayers.org/en/latest/examples/feature-animation.html
我尝试替换这些行中的样式:
var style = new ol.style.Style({
image: new ol.style.Circle({
radius: radius,
snapToPixel: false,
stroke: new ol.style.Stroke({
color: 'rgba(255, 0, 0, ' + opacity + ')',
width: 0.25 + opacity
})
})
});
vectorContext.setStyle(style);
当我将样式替换为 img 样式时,如下所示:
var style = new ol.style.Style({
image: new ol.style.Icon(({
src: 'https://openlayers.org/en/v3.20.1/examples/data/icon.png'
}))
});
它不起作用并引发错误:无法读取 null 的属性“0”
这是一个错误吗?或者我该如何使用img样式呢?
【问题讨论】:
-
我在您的代码中没有发现任何错误;一切都应该正常工作。您能否提供一个活生生的例子,以便我们了解正在发生的事情?
-
这是一个例子:jsfiddle.net/codingmiao/9gou6rwL/6,我只是在第53行改变了样式(原来的例子是openlayers.org/en/latest/examples/feature-animation.html),函数“animate”不能工作......
标签: openlayers-3