如何在xml中检索跨原点火山数据? [英] How to retrieve cross origin volcanic data in xml?
问题描述
我正在为自己的学位开发项目,其中一项要求是在Google地图上显示火山活动.但是,此资源 https://volcano.si.edu/database/webservices.cfm -我找不到其他可以提供此数据的地方,所有其他留言板都指向同一资源,但我对此感到困惑.
I'm in the process of developing a project for my degree, one of the requirements is to display volcanic activity on google maps. However I'm having CORS issues with this resource https://volcano.si.edu/database/webservices.cfm - There is nowhere else that I can find that provides this data, all other messageboards point to this same resource, but I am stumped at it.
我正在使用他们的100个全新火山样品,并直接从他们的示例中使用:
I'm using their sample of 100 holocene volcanoes and going direct from their example I'm using this:
$(document).ready(function(){
$.ajax({
type: 'GET',
url: "https://webservices.volcano.si.edu/geoserver/GVP-VOTW/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=GVP-VOTW:Smithsonian_VOTW_Holocene_Volcanoes&maxFeatures=100",
dataType: 'xml',
success: function (data) {
console.log(data);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
});
收到此结果:
在以下位置访问XMLHttpRequest ' http://127.0.0.1:3000 "已被CORS政策禁止: 请求中不存在"Access-Control-Allow-Origin"标头 资源.
Access to XMLHttpRequest at 'https://webservices.volcano.si.edu/geoserver/GVP-VOTW/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=GVP-VOTW:Smithsonian_VOTW_Holocene_Volcanoes&maxFeatures=100' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
推荐答案
AWS可以帮助您.
AWS can help you with this.
- 创建一个帐户并转到API网关.
- 创建一个新的API并选择您的协议并命名.
- 选择操作按钮,创建方法,选择GET.
- 选择http,然后将您的URL插入为端点
- 再次选择位置,选择启用CORS,单击下一步",一切就这样
- 部署API,命名阶段,然后使用它提供的URL从AJAX请求中进行调用
因此,将要发生的事情是您将调用AWS-API网关,该网关将把您的请求传递到火山端点. AWS将通过设置正确的请求头来处理CORS问题.
so what is going to happen is you are going to call AWS-API Gateway, which will pass your request thru to the volcano endpoint. AWS will handle the CORS issues by setting the proper headers coming back on the request.
玩得开心!
这篇关于如何在xml中检索跨原点火山数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!