[OpenLayers-Users] Popup over GPX track

Francesco webfrank at tiscali.it
Tue May 11 12:43:19 EDT 2010


Hi,
     I'm trying to display a popup on mouse over GPX track. This is the 
code used to load the track:

var lgpx = new OpenLayers.Layer.Vector("Track", {
                 style: {strokeColor: 'red', strokeWidth: 10, 
strokeOpacity: 0.5},
                 projection: map.displayProjection,
                 strategies: [new OpenLayers.Strategy.Fixed()],
                 protocol: new OpenLayers.Protocol.HTTP({
                     url: 'gpx.php',
                     format: new OpenLayers.Format.GPX()
                 })
             });

             map.addLayer(lgpx);

             lgpx.events.register('loadend',lgpx,function() {
                 var bounds = this.getDataExtent();
                 map.zoomToExtent(bounds);
             });
             var hoverSelect = new OpenLayers.Control.SelectFeature(lgpx, {
                 hover: true,
                 onSelect: function(feature) {

--------------> Here I want to display a popup with info from the GPX file

                 },
                 onUnselect: function(feature) {
                         if (feature.popup) {
                         map.removePopup(feature.popup);
                         feature.popup.destroy();
                         delete feature.popup;
                     }
                 }
             });
             map.addControl(hoverSelect);
             hoverSelect.activate();

I cannot find a way to get the currently selected track segment and 
extract attributes to display inside the popup.

Any idea?

Tnx
Francesco



More information about the Users mailing list