I reassemble the KML that is already loaded on a map similar to the example here: http://openlayers.org/dev/examples/sundials.html and turn it into a clickable list that will center the map on the click of a dot and display a popup for her.
It was very easy to do in Google Maps, but I can not find similar examples of Openlayers. Is there an easier way to do this? Is there something inbuilt that I am missing?
HTML
<ul id="locationTable"> </ul>
JS:
htmlRows = ""; for(var feat in features) { // Build details table featId = features[feat].id; // determine the feature ID title = jQuery(f).filter('[name=TITLE]').text(); htmlRow = "<li><a href="javascript:selectFeature('"+featId+"');\">"+title+"</a></li>"; htmlRows = htmlRows + htmlRow; } jQuery('#locationTable').append(htmlRows);
And then for the selectFeature function:
function selectFeature(fid) { for(var i = 0; i<kml.features.length;++i) { if (kml.features[i].id == fid) { selected = new OpenLayers.Control.SelectFeature(kml.features[i]); selected.clickFeature();
javascript openstreetmap openlayers
Chris
source share