【问题标题】:Reading in a GeoJSON page with AngularJS [duplicate]使用 AngularJS 读取 GeoJSON 页面 [重复]
【发布时间】:2016-02-22 12:04:45
【问题描述】:

我花了几个小时试图弄清楚如何使用 GeoJSON、AngularJS 和 $http.get 来读取 URL 页面。我从以下示例开始:

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

但它似乎不适用于 GeoJSON 网页。我尝试使用 Leaflet,但我也无法让它工作。我尝试使用 $http.get 使用 AngularJS 读取的 GeoJSON 页面是:

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

难道不能在 GeoJSON 页面上使用 AngularJS 和 $http.get 吗?如果有人可以提供任何建议,我将不胜感激。谢谢。

戴夫

【问题讨论】:

  • 你的意思是它不工作?您有一些内容返回,但它不被识别为 GeoJSON ?也许在数据上使用 JSON.parse ?
  • 关于上面的duplicate,问题是没有CORS头。此外,要加载到 Angular 应用程序中,大约 22MB 有点大

标签: json angularjs gis geojson


【解决方案1】:

我测试时服务器不允许跨域请求:XMLHttpRequest 无法加载http://eric.clst.org/wupl/Stuff/gz_2010_us_050_00_500k.json。请求的资源上不存在“Access-Control-Allow-Origin”标头。尝试定位允许 CORS 的其他 API。

【讨论】:

    猜你喜欢
    • 2010-10-06
    • 2018-05-11
    • 2012-11-13
    • 1970-01-01
    • 2015-07-21
    • 2014-04-15
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多