开发者

External listing of dynamic marker info of current view

I'm trying to figure out how to display dynamic markers in the form of a list within a separate div using openlayers, however I'm hoping to only display those seen within the current view. This means that whenever the map is moved, the list of marker info changes. Does anyone have any suggestions for achieving this? I'm still learning 开发者_StackOverflow中文版openlayers, so I apologize if the answer to this question should be obvious. Thank you in advance.


You could register for the map's moveend event and check which features are displayed using the onScreen() method.

var map = new Openlayer.Map( ... );
var layer = new OpenLayers.Layer.Vector( ... );

map.events.register('moveend', this, function() {
    var displayedFeatures = [];

    for (var i=0, len=layer.features.length; i<len; i++) {
        var feature = layer.features[i];
        if (feature.onScreen())
            displayedFeatures.push(feature);
    }

    //Do somthing with displayedFeatures

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜