简体   繁体   English

在Openlayers-3中使用JSON添加矢量层时出错

[英]Getting error in adding vector layer using JSON with Openlayers-3

I am new to openlayers and javascript. 我是openlayers和javascript的新手。 I was trying to add a vector layer on top of a tile layer as instructed in the example ( http://openlayers.org/ol3-workshop/layers/vector.html ). 我试图按照示例( http://openlayers.org/ol3-workshop/layers/vector.html )中的说明在平铺层上添加一个矢量层。 Code and the urls are perfect. 代码和网址是完美的。 Opening the file on the browser shows the map but without the vector layer. 在浏览器中打开文件会显示地图,但没有矢量层。 When I checked the javascript console on the browser, it shows this error: 当我在浏览器上检查javascript控制台时,它显示此错误:

XMLHttpRequest cannot load file:///C:/Users/tanwar/Desktop/MapProject/v3.6.0/7day-M2.5.json. XMLHttpRequest无法加载file:/// C:/Users/tanwar/Desktop/MapProject/v3.6.0/7day-M2.5.json。 Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. 跨源请求仅支持以下协议方案:http,数据,chrome-extension,https,chrome-extension-resource。

What does this error mean, I am not able to understand? 我看不懂此错误是什么意思? How can I make it correct? 我该如何纠正?

You have a cross-origin problem. 您有跨域问题。 The data cannot be read from a source different to your development domain. 无法从与您的开发域不同的来源读取数据。 Are you testing this on your localhost? 您要在本地主机上对此进行测试吗? My recommendation is to test with local data first. 我的建议是首先使用本地数据进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM