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

Cannot see GPS track on map using OpenLayers vector layer

0

Sorry for the bad formatting as I am new to this.

I am using the code from here: http://wiki.openstreetmap.org/wiki/Openlayers_Track_example

and I have used the GPX data from here: http://forum.openstreetmap.org/viewtopic.php?id=17278 and stored it in a static file on disk c:\tracks.gpx

And this is how I create the layer:

var lgpx = new OpenLayers.Layer.Vector("Lakeside cycle ride", "c:/tracks.gpx",{
                strategies: [new OpenLayers.Strategy.Fixed()],
                protocol: new OpenLayers.Protocol.HTTP({
                    format: new OpenLayers.Format.GPX()
                }),
                style: {strokeColor: "green", strokeWidth: 5, strokeOpacity: 0.5},
                projection: new OpenLayers.Projection("EPSG:4326")
            });
            map.addLayer(lgpx);

What am I doing wrong ?

asked 17 Apr '13, 09:10

CarTay's gravatar image

CarTay
6112
accept rate: 0%

edited 17 Apr '13, 12:27

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


One Answer:

4

have a look in your JavaScript error console (ctrl+shift+J in Firefox and some other browsers).

I could imagine that the read access to that local file via JavaScript in your browser is not allowed by your browser (even if your user may have read access). Try to place the html file and the gpx file on a web server.

Mention what your problem was if you solved it.

answered 17 Apr '13, 12:35

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

edited 19 Apr '13, 02:26

Thanks for the suggestion, will try it out and post the results.

(19 Apr '13, 01:45) CarTay
2

By moving the file to my web server the map now displays the contents of the .px file. Awesome !

Thanks aseerel4c26 !

(19 Apr '13, 02:41) CarTay

Thanks for the feedback. You really may see helpful errors/messages in the console (clear before running the script).

I have clarified the wiki page a bit.

(19 Apr '13, 02:59) aseerel4c26 ♦