简体   繁体   English

使用Openlayers打开Jquery Mobile弹出窗口时,如何使其定位在标记上?

[英]How do i get the Jquery Mobile popup to position over the marker when I open it using Openlayers?

Below is my code. 下面是我的代码。 I cleaned up and modified the addMarkers function, so i know that it is not going to work in this example but just wanted to shorten it down to show what I was doing. 我清理并修改了addMarkers函数,因此我知道它在本示例中不起作用,而只是想缩短它以显示我在做什么。

I am having a hard time figuring out how to set the position of the popup. 我很难弄清楚如何设置弹出窗口的位置。 I thought positionto: event.target would work but it is not coming back with anything in target. 我以为positionto:event.target可以工作,但是没有返回target中的任何东西。 Any ideas? 有任何想法吗? I want it to popup like most items do from when you click on a marker on a map. 我希望它像大多数项目一样在您单击地图上的标记时弹出。

 function addMarkers(json){
        for (var i=0;i<json.records.record.length;i++){

            // Make Point
            point = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat);
            feature = new OpenLayers.Feature.Vector(point);
            layer.addFeatures(feature);
        }
        map.addLayer(layer[0]);
    }
}


var selectControl = new OpenLayers.Control.SelectFeature(
    [vectorlayer1, vectorlayer2],
    {
        clickout: true, toggle: false,
        multiple: false, hover: false
    }
);

vectorlayer1.events.on({
    "featureselected": popup,
    "featureunselected": function(e) {
        alert("unselected feature "+e.feature.id+" on vectorlayer 1");
    }
});

 function popup(event){
    $("#popup").popup('open', {
        positionTo: event.target
    });
}

From Jquery mobile docs : 'positionTo' parameter must be a string ('origin' or 'window') or a JQuery selector. Jquery mobile docs中 :“ positionTo”参数必须是字符串 (“ origin”或“ window”)或JQuery选择器。 In this case $(event.target) will work. 在这种情况下,$(event.target)将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM