我正在使用 OpenLayers (OL3) 在地图上显示形状和对象。
这些形状代表建筑物,并将具有 SVG 或 PNG 格式的图像资源。我需要将这些图像以适当的比例和旋转放置在地图上,并且仍然能够缩放/平移。
我在这里找到了一个使用 OpenLayers 2 的非常好的示例:http: //gis.ibbeck.de/ginfo/apps/OLExamples/OL27/examples/ExternalGraphicOverlay/ExternalGraphicOverlay.asp
我在将其转换为 OL3(地图旋转需要它)时遇到问题。我被卡住的是这个(OL2中的示例代码):
var context = {
getW : function(){
return theWidth * theResolution / map.getResolution();
},
getH : function(){
return theHeight * theResolution / map.getResolution();
},
getR : function(){
return theRotation;
}
};
var template = {
graphicWidth : "${getW}",
graphicHeight : "${getH}",
rotation : "${getR}"
};
var styleMap = OpenLayers.Style(template, {context: context});
vectorLayer.styleMap = styleMap;
我没有找到如何将其转换为 ol.style.Style 以在缩放时缩放的图层上设置图像。
如何使用 OL3 实现这一点?