<!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>
style: {strokeColor: 'red', strokeWidth: 10,
strokeOpacity: 0.5},<br>
projection: map.displayProjection,<br>
strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.HTTP({<br>
url:
'gpx.php?imei='+imei+'&from='+from+'&to='+to,<br>
format: new OpenLayers.Format.GPX({<br>
extractAttributes: true,<br>
extractStyles: false,<br>
maxDepth: 4,<br>
extractTracks: true,<br>
extractRoutes: false,<br>
extractWaypoints: false<br>
})<br>
})<br>
});<br>
<br>
map.addLayer(lgpx);<br>
<br>
lgpx.events.register('loadend',lgpx,function() {<br>
var bounds = this.getDataExtent();<br>
map.zoomToExtent(bounds); <br>
});<br>
<br>
var hoverSelect = new
OpenLayers.Control.SelectFeature(lgpx, {<br>
hover: true, <br>
multiple: true,<br>
geometryTypes: ["OpenLayers.Geometry.LineString"],<br>
renderIntent: "temporary",<br>
onSelect: function(f) {<br>
var content = 'popup';<br>
popup = new OpenLayers.Popup.FramedCloud("Info",<br>
f.geometry.getBounds().getCenterLonLat(),<br>
null,<br>
content,<br>
null, true, function() {<br>
hoverSelect.unselectAll();<br>
}<br>
);<br>
f.popup = popup;<br>
map.addPopup(popup);<br>
},<br>
onUnselect: function(f) {<br>
if (f.popup) {<br>
map.removePopup(f.popup);<br>
f.popup.destroy();<br>
delete f.popup;<br>
}<br>
}<br>
}); <br>
map.addControl(hoverSelect);<br>
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"><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>"><br>
</span><span class="webkit-html-tag"><trk <span
class="webkit-html-attribute-name">xmlns</span>="<span
class="webkit-html-attribute-value"></span>"><br>
</span><span class="webkit-html-tag"><trkseg></span><span
class="webkit-html-tag"><br>
<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>"><br>
</span><span class="webkit-html-tag"> <time></span>2010-05-16T10:46:10Z<span
class="webkit-html-tag"></time><br>
</span><span class="webkit-html-tag"> <name></span>0<span
class="webkit-html-tag"></name><br>
</span><span class="webkit-html-tag"> </trkpt><br>
</span></span></span> .............<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) {
--------------> 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>