Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an OpenLayers map a few thousand Points of Interest. These POIs are Vector Features rendered in a Vector Layer.

We are loading the POIs once in order to minimize load on the server.

Next to the map will be a box which will display the names of POIs currently in view.

I'm not clear on the best way to update this list of names.

I believe that I can store an array of the POIs (Features). Then, when the map is panned/searched/zoomed, loop through them, calling the "onScreen" function."moveend", map, function(evt) {
      var output = [];
      for (var i=0;i<myFeatures.length;i++) {
          var poi = myFeatures[i];
          if (poi.onScreen()){
     // then, use output to display the list in html...
     myDOMbox.innerHTML = output.join();


Is there a more efficient way to do this?

Thanks in advance.

share|improve this question
up vote 2 down vote accepted

Not quite sure what your "onScreen" function is, but an example that should work is this:"moveend", map, function(evt) {
    var extent = map.getExtent();
    var output = [];
    for (var i = 0, l = myFeatures.features.length; i < l; i++) {
        var feature = myFeatures.features[i];
        if (extent.intersectsBounds(feature.geometry.getBounds())) {
share|improve this answer
Thanks. The onScreen function is part of the api here:… I'm guessing that it does the same thing as your intersectBounds function. Much appreciated though. – shackleton May 14 '13 at 17:10
Aha, seems OpenLayers has got guite a few new features lately. I guess my solution is akin to setting boundsOnly to true on onScreen. But either way, you have to somehow loop through all features to check them. Glad to help! – atlefren May 14 '13 at 20:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.