<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I tried with this code:<br>
var lgpx = new OpenLayers.Layer.Vector("Track", {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; style: {strokeColor: 'red', strokeWidth: 10,
strokeOpacity: 0.5},<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; projection: map.displayProjection,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; strategies: [new OpenLayers.Strategy.Fixed()],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; protocol: new OpenLayers.Protocol.HTTP({<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; url:
'gpx.php?imei='+imei+'&amp;from='+from+'&amp;to='+to,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; format: new OpenLayers.Format.GPX({<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractAttributes: true,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractStyles: false,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; maxDepth: 4,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractTracks: true,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractRoutes: false,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractWaypoints: false<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; })<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; })<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.addLayer(lgpx);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lgpx.events.register('loadend',lgpx,function() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var bounds = this.getDataExtent();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.zoomToExtent(bounds);&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var hoverSelect = new
OpenLayers.Control.SelectFeature(lgpx, {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hover: true, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; multiple: true,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; geometryTypes: ["OpenLayers.Geometry.LineString"],<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderIntent: "temporary",<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; onSelect: function(f) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var content = 'popup';<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; popup = new OpenLayers.Popup.FramedCloud("Info",<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; f.geometry.getBounds().getCenterLonLat(),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; null,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; content,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; null, true, function() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hoverSelect.unselectAll();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; f.popup = popup;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.addPopup(popup);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; },<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; onUnselect: function(f) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (f.popup) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.removePopup(f.popup);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; f.popup.destroy();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; delete f.popup;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.addControl(hoverSelect);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hoverSelect.activate();<br>
<br>
and the GPX file is like this:<br>
<span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span
 class="Apple-style-span"
 style="font-family: monospace; white-space: pre-wrap;"><span
 class="webkit-html-tag">&lt;gpx <span
 class="webkit-html-attribute-name">xmlns</span>="<span
 class="webkit-html-attribute-value"><a class="moz-txt-link-freetext" href="http://www.topografix.com/GPX/1/1">http://www.topografix.com/GPX/1/1</a></span>"
<span class="webkit-html-attribute-name">xmlns:xsi</span>="<span
 class="webkit-html-attribute-value"><a class="moz-txt-link-freetext" href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a></span>"
<span class="webkit-html-attribute-name">version</span>="<span
 class="webkit-html-attribute-value">1.1</span>" <span
 class="webkit-html-attribute-name">creator</span>="<span
 class="webkit-html-attribute-value">Waze Mobile Ltd (1.4.0.1) -
<a class="moz-txt-link-freetext" href="http://roadmap.digitalomaha.net/editor.html">http://roadmap.digitalomaha.net/editor.html</a></span>" <span
 class="webkit-html-attribute-name">xsi:schemaLocation</span>="<span
 class="webkit-html-attribute-value"><a class="moz-txt-link-freetext" href="http://www.topografix.com/GPX/1/1">http://www.topografix.com/GPX/1/1</a>
<a class="moz-txt-link-freetext" href="http://www.topografix.com/GPX/1/1/gpx.xsd">http://www.topografix.com/GPX/1/1/gpx.xsd</a></span>"&gt;<br>
</span><span class="webkit-html-tag">&lt;trk <span
 class="webkit-html-attribute-name">xmlns</span>="<span
 class="webkit-html-attribute-value"></span>"&gt;<br>
</span><span class="webkit-html-tag">&lt;trkseg&gt;</span><span
 class="webkit-html-tag"><br>
&lt;trkpt <span class="webkit-html-attribute-name">lat</span>="<span
 class="webkit-html-attribute-value">37.0617024</span>" <span
 class="webkit-html-attribute-name">lon</span>="<span
 class="webkit-html-attribute-value">14.9067984</span>"&gt;<br>
</span><span class="webkit-html-tag"> &lt;time&gt;</span>2010-05-16T10:46:10Z<span
 class="webkit-html-tag">&lt;/time&gt;<br>
</span><span class="webkit-html-tag"> &lt;name&gt;</span>0<span
 class="webkit-html-tag">&lt;/name&gt;<br>
</span><span class="webkit-html-tag"> &lt;/trkpt&gt;<br>
</span></span></span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .............<br>
<br>
I would like to display inside the popup time and name attributes<br>
<br>
Il 11/05/2010 19.11, emmexx ha scritto:
<blockquote cite="mid:4BE98FC9.5050000@tiscalinet.it" type="cite">
  <pre wrap="">Il 11/05/2010 18:43, Francesco scrisse:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi,
     I'm trying to display a popup on mouse over GPX track. This is the 
code used to load the track:
    </pre>
  </blockquote>
  <pre wrap="">
  </pre>
  <blockquote type="cite">
    <pre wrap="">                 onSelect: function(feature) {

--------------&gt; Here I want to display a popup with info from the GPX file

                 },
                 onUnselect: function(feature) {
    </pre>
  </blockquote>
  <pre wrap="">
I use eventListeners instead of onSelect onUnselect.

bye
        maxx


  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <blockquote type="cite">
        <pre wrap="">Code for the popup:
        </pre>
      </blockquote>
    </blockquote>
  </blockquote>
  <pre wrap="">
        var highlightCtrl = new OpenLayers.Control.SelectFeature([vlayer,
clayer], {
                hover: true,
                highlightOnly: true,
                multiple: true,
                geometryTypes: ["OpenLayers.Geometry.LineString"],
                renderIntent: "temporary",
                eventListeners:
                {
                        featurehighlighted: function(f)
                        {
                                popup = new OpenLayers.Popup("mylayer",
f.feature.geometry.getBounds().getCenterLonLat(),
null,
'some html text',
null,
true);
                                 popup.autoSize=true;
//                                 popup.panMapIfOutOfView=true;
                                f.feature.popup = popup;
                                map.addPopup(popup);
                        },
                        featureunhighlighted: function(f)
                        {
                    map.removePopup(f.feature.popup);
                    f.feature.popup.destroy();
                    f.feature.popup = null;

                        }
                }        
        });

        map.addControl(highlightCtrl);

        highlightCtrl.activate();

(popup is a global variable)

  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <blockquote type="cite">
        <blockquote type="cite">
          <pre wrap="">Code to open a gpx file:
          </pre>
        </blockquote>
      </blockquote>
    </blockquote>
  </blockquote>
  <pre wrap="">
                var tmplayerGps= new OpenLayers.Layer.GML('myfile', path,
                {
                                format:  OpenLayers.Format.GPX,
                                formatOptions: {
                                        extractAttributes: true,
                                        extractStyles: false,
                                        maxDepth: 2,
                                        extractTracks: true,
                                        extractRoutes: false,
                                        extractWaypoints: false
                                },
                                'styleMap': styleMap,
                                projection: map.displayProjection
                });


  </pre>
</blockquote>
</body>
</html>