If you are providing a StyleMap to the layer, you should drop the 'style' property in the layer definition.

Matt Priour


On 12/14/2012 8:33 AM, Digby Maass wrote:
display waypoints from a gpx file 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


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to