[OpenLayers-Users] display waypoints from a gpx file
Digby Maass
digbymaass at gmail.com
Fri Dec 14 06:33:14 PST 2012
I can display a gpx trace on a map eg:
http://www.carnethy.com/maps/wed_training/iframecontent/121212nightrun.htm
(attached)
But I can't work out how to display waypoints with their names. Can anyone
help?
Nothing happens if I change this:
var lgpx = new OpenLayers.Layer.Vector("wed training", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "../../gpx/wed-training/12-Dec-12.gpx",
format: new OpenLayers.Format.GPX()
}),
style: {strokeColor: "red", strokeWidth: 3, strokeOpacity:
0.8},
projection: new OpenLayers.Projection("EPSG:4326")
});
to this:
var lgpx = new OpenLayers.Layer.Vector("wed training", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "../../gpx/wed-training/12-Dec-12.gpx",
format: new OpenLayers.Format.GPX({extractWaypoints:
true, extractRoutes: true, extractAttributes: true})
}),
style: {strokeColor: "red", strokeWidth: 3, strokeOpacity:
0.8},
styleMap: gpxStyles,
projection: new OpenLayers.Projection("EPSG:4326")
});
and define gpxStyles thus:
var gpxStyles = new OpenLayers.StyleMap({"default": new OpenLayers.Style({
pointRadius: "5", // sized according to type attribute
label: "${wpt}",
labelAlign: 'cb',
fontSize: 9,
fontFamily: "Arial",
fontColor: "red",
labelYOffset: 6,
fillColor: "brown",
strokeColor: "yellow",
strokeWidth: 2,
strokeOpacity: 1
}),
"select": new OpenLayers.Style({fillColor: "#66ccff",
strokeColor: "#3399ff",graphicZIndex: 2
})
});
Thanks
Digby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121214/26e13410/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 121212nightrun.htm
Type: application/octet-stream
Size: 5071 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121214/26e13410/attachment.obj>
More information about the Users
mailing list