Openlayers 3 在OpenLayers 3中的地图上覆盖多个图像
我有一个服务,它返回一组图像,每个图像有4个坐标(左上、右上、左下、右下) 有没有办法在地图上显示这些图像?到目前为止,这是我的样式功能,但只显示笔划:Openlayers 3 在OpenLayers 3中的地图上覆盖多个图像,openlayers-3,Openlayers 3,我有一个服务,它返回一组图像,每个图像有4个坐标(左上、右上、左下、右下) 有没有办法在地图上显示这些图像?到目前为止,这是我的样式功能,但只显示笔划: function(feature) { var EO = feature.get('source'); return [new ol.style.Style({ image: new ol.style.Icon({ src: EO.image, rotateWit
function(feature) {
var EO = feature.get('source');
return [new ol.style.Style({
image: new ol.style.Icon({
src: EO.image,
rotateWithView: true,
}),
stroke: new ol.style.Stroke({
color: '#00F',
width: 1
})
})]
}
这是我的虚拟对象数组:
var dummy = [
{
coords: [
[-9.223774, 38.755317],
[-9.124210, 38.707109],
[-9.158542, 38.664230],
[-9.258964, 38.711396]
],
image: 'dummy/eo/eo1.jpg'
}
];
以下是将虚拟对象转化为特征的循环:
dummy.forEach(function(EO) {
var projectedCoords = EO.coords.map(function(coord) {
return ol.proj.fromLonLat(coord, 'EPSG:3395');
});
var EOFeature = new ol.Feature(new ol.geom.Polygon([projectedCoords]));
EOFeature.set('source', {
image: EO.image
});
EOFeature.set('type', 'EO');
features.push(EOFeature);
});
您的函数看起来不错,因为
EO.image
是有效的源代码。也许你会展示更多的代码。EO.image
是一个有效的源代码。问题是style.Icons
只接受点几何体,我想传入一个多边形几何体。此外,图标
与比例无关。我用更多的代码更新了原来的问题。你想让图像覆盖整个多边形吗?这就是我的想法,是的。我认为这是不可能的,你见过这样的例子吗?