This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

[closed] display waypoint names in openlayers map

0

I can easily display a GPX track on an openlayers map using the example code at https://wiki.openstreetmap.org/wiki/Openlayers_Track_example

or by using this alternative code I can also display waypoints (but not their names):

var myStyleMap = new OpenLayers.StyleMap({"default": new OpenLayers.Style({pointRadius: 5, fillColor: "darkred", strokeColor: "red",    strokeWidth: 3  })
            });
// add the layer with the GPX track and waypoints
var lgpx = new OpenLayers.Layer.Vector("title", {
protocol: new OpenLayers.Protocol.HTTP({ url: "my_file.gpx",
format: new OpenLayers.Format.GPX({extractWaypoints: true,  extractName: true, extractRoutes: true, extractAttributes: true})
}),
strategies: [new OpenLayers.Strategy.Fixed()],
styleMap: myStyleMap, 
projection: new OpenLayers.Projection("EPSG:4326")
});
map.addLayer(lgpx);

I would like to be able to display the names of the waypoints. The waypoints are in the GPX file in the following format:

<wpt lat="55.90119934" lon="-3.15706110">
        <ele>129.4</ele>
        <time>2010-12-22T20:43:20Z</time>
        <name>The Waverley</name>
</wpt>

I can't fathom the javascript, and there are no examples on the web. Can anyone help?

asked 14 Jan '12, 16:03

digby's gravatar image

digby
465612
accept rate: 0%

closed 14 Jan '12, 17:07

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273

The question has been closed for the following reason “Question is off-topic or not relevant” by Frederik Ramm 14 Jan ‘12, 17:07


One Answer:

0

See Getting Help on the OpenLayers forum for ways to find help with OpenLayers. This is the OpenStreetMap help system and your question is not related to OpenStreetMap.

answered 14 Jan '12, 17:07

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

As far as I'm concerned openlayers is linked with openstreetmap. If you look at the quote above you'll see the link https://wiki.openstreetmap.org/wiki/Openlayers_Track_example The openlayers help is messy and confusing. The first line "How can I add a question to this FAQ?" does nothing to answer the question. Ironically.

(13 Dec '12, 15:16) digby

I'll add to that comment. There is no OpenLayers forum. OpenLayers help is terrible. It is no help at all. In fact I can't find any way of asking a question.

(14 Dec '12, 13:55) digby

Try the mailing list or Stack Exchange (GIS, Stackoverflow).

(14 Dec '12, 14:02) scai ♦

I found the answer. But I'm not telling you.

(28 Mar '13, 16:57) digby

Source code available on GitHub .