2

我有一张带有矢量图层的地图,显示来自 GeoJSON 的特征。当我悬停该功能时,在线串的开头会出现一个弹出窗口。但它在闪烁,它出现又消失。我猜该功能会以某种方式被取消选择。也许弹出窗口位于鼠标和功能之间的中间,因此不再满足悬停功能的条件。我该如何解决?我希望在鼠标悬停在功能上时显示弹出窗口,无论弹出窗口是否挡道。

我认为即使使用示例代码也可以复制它:http: //openlayers.org/dev/examples/light-basic.html

即使我的鼠标没有直接位于弹出窗口的白色部分上,也会发生这种情况。

在我看来,chrome 的问题比 Firefox 更严重。也许这不是我的代码的问题,而是错误。如果是这样,很抱歉在这里发帖。

闪烁的弹出窗口

我正在使用愚蠢的代码:

    layer = new OpenLayers.Layer.Vector("JOSM", {
                eventListeners: {
                    'featureselected': function(evt) {

                        var feature = evt.feature;
                        var detailsTextHtml = "";
                        var lines = feature.attributes.evaluations.split("\n");
                        for (var i = 0; i < lines.length; i++) {
                            if (lines[i] !== "") {
                                detailsTextHtml += " <br> " + lines[i];
                            }
                        }
                        popup = new OpenLayers.Popup.FramedCloud("popup",
                                OpenLayers.LonLat.fromString(feature.geometry.getVertices()[0].toShortString()),
                                null,
                                "<div style='font-size:.8em'>Coefficient: " + feature.attributes.coefficient + "<br>Color:" + feature.attributes.color + "<br>Details: " + detailsTextHtml + "</div>",
                                null,
                                true
                                );
                        feature.popup = popup;
                        map.addPopup(popup);
                    },
                    'featureunselected': function(evt) {
                        var feature = evt.feature;
                        map.removePopup(feature.popup);
                        feature.popup.destroy();
                        feature.popup = null;

                    }
                },
                styleMap: styleMap,
                strategies: [new OpenLayers.Strategy.Fixed()],
                projection: geographic,
                protocol: new OpenLayers.Protocol.HTTP({
                    url: "webresources/getJosmAspectsDetailed?startLon=" + document.getElementById('startLon').value +
                            "&startLat=" + document.getElementById('startLat').value +
                            "&endLon=" + document.getElementById('endLon').value +
                            "&endLat=" + document.getElementById('endLat').value + "&speed=17&comfort=0&quietness=0",
                    format: new OpenLayers.Format.GeoJSON()
                })
            });
4

0 回答 0