Graphileon
Graphileon

Reputation: 5385

loading an external GeoJSON into Openlayers

To get familiar with GeoJSON / Openlayers , I tried to use this example

http://gis-lab.info/share/DR/sandbox/geojson.html (found it here on stackoverflow)

first step was to copy the html locally a and change the url to the geojson file from

"./data/l1.geojson" 

to

"http://gis-lab.info/share/DR/sandbox/data/l1.geojson"

no other changes made, but it didn't work ..

2nd try was to just put the geojson file locally.

didn't work either

What am I missing ?

Upvotes: 1

Views: 1338

Answers (1)

capdragon
capdragon

Reputation: 14899

Try copying that data locally to "./data/l1.geojson" to avoid Cross-domain issues. Be aware of the browser's same origin policy.

If calling the that exists on a seperate domain is a requirement, then get the data first using Ajax, JSONP or back-end proxy then feed it into openlayers. read up on this.

Upvotes: 1

Related Questions