【发布时间】:2018-05-10 19:46:32
【问题描述】:
我正在使用 ol.geom.Polygon 对象来绘制一个多边形,并在其中添加了一个工具提示来显示这样绘制的英亩数。
if (geom instanceof ol.geom.Polygon) {
MapValues.polyAcres = MapService.formatArea(geom);
tooltipCoord = geom.getInteriorPoint().getCoordinates();
MapValues.measureTooltipElement.innerHTML = MapValues.polyAcres;
MapValues.measureTooltip.setPosition(tooltipCoord);
更新
这就是我创建工具提示的方式...
mapSVC.createMeasureTooltip = function(){
if (MapValues.measureTooltipElement) {
MapValues.measureTooltipElement.parentNode.removeChild(MapValues.measureTooltipElement);
}
MapValues.measureTooltipElement = document.createElement('div');
MapValues.measureTooltipElement.className = 'tooltip tooltip-measure';
MapValues.measureTooltipElement.style = 'pointer-events: none';
MapValues.measureTooltip = new ol.Overlay({
element: MapValues.measureTooltipElement,
offset: [0, -15],
positioning: 'bottom-center'
});
MapValues.mapObj.addOverlay(MapValues.measureTooltip);
}
问题是,根据绘制的形状,一个点和工具提示可能重叠,这实际上阻碍了我设置点的能力。
如何将样式“指针事件:无”添加到 ol.Overlay?
【问题讨论】:
-
将此 css 添加到您的工具提示 div
pointer-events: none;尽管您提供的信息不足以正确指导您 -
好的...看起来这样可行,但我还需要将样式添加到包含的 ol.Overlay...我看不到办法吗?
-
对反对票的评论表示赞赏,它不仅对我有帮助,而且每个人都了解如何更好地提出他们的问题。
-
尝试在
ol.css文件的ol-overlaycontainer类中添加相同的代码。如果您提供有关您的案例的小提琴,我们可能会更适当地帮助您。
标签: openlayers openlayers-3 angular-openlayers