[OpenLayers-Users] Popup over GPX track
emmexx
emmexx at tiscalinet.it
Tue May 11 13:11:37 EDT 2010
Il 11/05/2010 18:43, Francesco scrisse:
> Hi,
> I'm trying to display a popup on mouse over GPX track. This is the
> code used to load the track:
> onSelect: function(feature) {
>
> --------------> Here I want to display a popup with info from the GPX file
>
> },
> onUnselect: function(feature) {
I use eventListeners instead of onSelect onUnselect.
bye
maxx
>>> Code for the popup:
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)
>>>> Code to open a gpx file:
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
});
More information about the Users
mailing list