NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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


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.

permanent link

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 ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×255
×122

question asked: 17 Apr '13, 09:10

question was seen: 5,948 times

last updated: 19 Apr '13, 02:59

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum