简体   繁体   English

在Openlayers中打开Geojson文件

[英]Opening Geojson file in Openlayers

I have gone through all codes here explaining how to add geojson file in openlayers.But is there way to add the same from a local drive something like 我已经遍历了所有代码,解释了如何在openlayers中添加geojson文件。但是有没有办法从本地驱动器中添加相同的内容,例如

c:\\test\\sample.geojson c:\\ test \\ sample.geojson

instead of URL like 而不是像这样的URL

www.sdssd.com\\sample.geojson www.sdssd.com \\ sample.geojson

I mean is it mandatory to host a geojson file and then only open it. 我的意思是必须托管一个geojson文件,然后才打开它。

please help. 请帮忙。

Shyam 夏姆

Opening from a local drive will not work. 从本地驱动器打开将不起作用。

This would be a huge security hole in each browser. 这将是每个浏览器中的一个巨大安全漏洞。 Only workaround is to provide an upload feature so users can upload the geojson file to your server, and after uploaded, displayed from that server. 唯一的解决方法是提供上传功能,以便用户可以将geojson文件上传到您的服务器,并在上传后从该服务器显示。

I don't really use Openlayers for using Geojson (prefer Leaflet.js), but it would probably open in your local drive if that's where the HTML file referenced it. 我并没有真正使用Openlayers来使用Geojson(更喜欢Leaflet.js),但是如果HTML文件引用了它,它可能会在本地驱动器中打开。 No one else would be able to use it though unless they downloaded it into the same directory structure as you. 除非他们将其下载到与您相同的目录结构中,否则其他人将无法使用它。

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

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