Trigger a pop-up or recenter in Openlayers (version 7.x-2.0-beta5) from outsite the map Is it possible to trigger the pop-up of a marker or center the marker in an Openlayers map through an anchor-tag outside the Openlayers map.

Example:


Create a view that lists some nodes
Click on the title of a node
Recenter the map or open the pop-up of the marker of that node.


I found this solution but they work with an older version of Openlayers and can't get it to work...
If you are using the standard popups that come with OL, you can make use of Drupal.openlayers.popup.popupSelect.clickFeature().  

The way I did this was to assign an html attribute "nid" to each node in the list of nodes that you are going to use for the click navigation.  You can grab the nid from the clicked node any way you like, this is just the way I had done it.

So, now you have your list of nodes with an nid attribute and your map full of markers.  Here's one way you can use Drupal.openlayers.popup.popupSelect.clickFeature() to open the popup when you click one of the nodes in your list:

Make sure namespace exists:

Drupal.settings.nid = Drupal.settings.nid || [];
Drupal.settings.getAllFeature;


Make Drupal aware of all layers features:

function my_map() {
  var all_layers = Drupal.openlayers.popup.popupSelect.layers;
  for(var key1 in all_layers) {
    var current_layer = all_layers[key1];
    var all_features_in_layer = current_layer.features;
    for(var key2 in all_features_in_layer) {
      var current_feature = all_features_in_layer[key2];
      Drupal.settings.nid[current_feature.attributes.nid] = current_feature;
    }
  }
}


Function to grab the map object:

function getMap() {
  return jQuery('.openlayers-map').data('openlayers');
}


Click function for each node in your list of nodes:

jQuery('.eachNodeInYourList').click(function(e) {
  var nid = jQuery(this).attr('nid');
  show_popup(nid);      
});


Show the popup on the map:

function show_popup(nid) {
  if (Drupal.settings.nid) {
    var feature = Drupal.settings.nid[nid];
    Drupal.openlayers.popup.popupSelect.clickFeature(feature);
  }
}


Make sure a layer is visible: (get the layer name from the "Title" field on the views overlay)

function activate_layer(aLayer) {
  var ol = getMap();
  var layer = ol.openlayers.getLayersByName(aLayer)[0];
  layer.setVisibility(true);
}


Initialize:

if (jQuery('.openlayers-map').length &gt; 0) {
  my_map();
  activate_layer('myLayer');
}