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

how to implement gpx-files in OSM

0

If I implement a gpx track from a file of my harddisk to an OpenLayer it works great as long as the gpx file is in the same directory or in a directory down. I receive the map from the internet and the track from the harddisk can be seen.

var GPXVariable_1 = new OpenLayers.Layer.Vector("Alpspitze", {

strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({
url:"Alpspitze.gpx", format: new OpenLayers.Format.GPX()
        }),  // works

... url:"directory_x/Alpspitze.gpx" // works

If I try to implement a gpx file that is in a different directory structure, it doesn't work.

... url:"../../directory_y/directory_z/Alpspitze.gpx" // doesn't work

What am I doing wrong? What is the correct syntax for the address?

This question is marked "community wiki".

asked 07 Aug '14, 17:56

flegar's gravatar image

flegar
26112
accept rate: 0%


2 Answers:

1

Maybe it is a security mechanism of the browser to prevent JavaScript code to read your whole file system and independent on OpenLayers.

answered 08 Aug '14, 12:29

MarkusHD's gravatar image

MarkusHD
375410
accept rate: 12%

1

In the meantime, I've got an answer from a different forum.

Unfortunatelly there ist a restriction that allows local documents having access to other local documents in the same directory and in subdirectories, but not directory listings.

When I change the config:about (Firefox) security.fileuri.origin_policy to false, the track gets visible although it is implemented from a different file tree.

Conclusion: Due to the security police of browsers I have to rearrange my directory.

answered 08 Aug '14, 12:46

flegar's gravatar image

flegar
26112
accept rate: 0%

Source code available on GitHub .