我正在尝试使用openlayers示例网站的示例代码创建一个用户交互循环:
var draw = new ol.interaction.Draw({
features: featureOverlay.getFeatures(),
type: 'Circle'
});
map.addInteraction(draw);当我设置为:Circle时,我总是得到一个Circle,但是当我将类型设置为Point、LineString或Polygon时,它工作得很好。我查看了OpenLays3API文档,Circle是一个有效的几何类型。这里有人知道为什么我会出现类型错误吗?
发布于 2015-05-20 10:44:41
循环被添加到ol3 (3.4)的最新版本之一,现在最新版本是3.5,我举了一个添加循环的例子:
js
https://cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol.jscss
https://cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol.min.css画圆
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'osm'})
})
],
view: new ol.View({
center: ol.proj.transform(
[-110, 45], 'EPSG:4326', 'EPSG:3857'),
zoom: 3
})
});
var featureOverlay = new ol.FeatureOverlay({
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
}),
stroke: new ol.style.Stroke({
color: '#ffcc33',
width: 2
}),
image: new ol.style.Circle({
radius: 7,
fill: new ol.style.Fill({
color: '#ffcc33'
})
})
})
});
featureOverlay.setMap(map);
var draw = new ol.interaction.Draw({
features: featureOverlay.getFeatures(),
type: 'Circle'
});
map.addInteraction(draw);https://stackoverflow.com/questions/30335149
复制相似问题