0

I spent hours trying to figure out how to read in a URL page with GeoJSON with AngularJS and $http.get. I started out with the example from:

http://www.w3schools.com/angular/angular_http.asp

but it doesn't seem to work with GeoJSON webpage. I tried using Leaflet but I couldn't get it to work either. The GeoJSON page I'm try to read in with AngularJS with $http.get is:

http://eric.clst.org/wupl/Stuff/gz_2010_us_050_00_500k.json

Is it not possible to use AngularJS and $http.get with GeoJSON pages? If anyone could provide any advice I would be very grateful. Thank you.

Dave

David
  • 1
  • What do you mean it's not working ? You have some content back but it's not recognized as GeoJSON ? Maybe use JSON.parse on the data ? – syldor Nov 20 '15 at 05:00
  • Regarding the above *duplicate*, the problem is no CORS headers. Also, ~22MB is kinda big to be loading into an Angular app – Phil Nov 20 '15 at 05:02

1 Answers1

0

The server doesn't allow cross-origin requests when I tested: XMLHttpRequest cannot load http://eric.clst.org/wupl/Stuff/gz_2010_us_050_00_500k.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Try targeting a different API that allows CORS.

randdusing
  • 41
  • 1
  • 2