1

I created an HTML page (currently locally) and used Leaflet to create a basic map to which I plan to add several shapefiles. To do this, I use the leaflet.shapefile extension (https://github.com/calvinmetcalf/leaflet.shapefile) and everything is working pretty good so far.

That is, in Firefox. If I test the page in Internet Explorer or Google Chrome, everything except for the shapefile I use for testing shows up.

I uploaded the page to mediafire (http://www.mediafire.com/download/wdib96x6udbnq2h/web.rar), index.html is the main page.

I consider myself pretty seasoned in GIS and Cartography terms, but I'm fairly green when it comes to the web stuff like HTML, so if this not the right question for this forum feel free to point it out : ) .

2
  • I zipped a shapefile up and drag it into the leaflet.calvinmetcalf.com/#3/32.69/10.55 site it loaded correctly - it took a little while in chrome but worked - you might be better using the export to leaflet in qgis... I find it works much better qgistutorials.com/en/docs/leaflet_maps_with_qgis2leaf.html
    – Mapperz
    Commented Jul 20, 2015 at 17:57
  • This Tool looks quite handy... thanks for brining it up me, will definetily take a look at it! But I still don't get why only Firefox displays the file correctly currently. Anybody got an idea on that
    – Marius_O
    Commented Jul 20, 2015 at 20:10

2 Answers 2

0

Are you running this locally? In the Chrome console (F12) I get a cross origin error on your zipped shapefile when trying to open index.html from the file system.

XMLHttpRequest cannot load file:///C:/Users/web/kaystros_osm_Project.zip.    
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Chrome is more strict about cross origin policy than Firefox is for local files.

There are many posts on stackoverflow about this. This (relatively old) answer, suggests that in Linux you may be able to disable this by running chrome with

chrome --disable-web-security

A somewhat more recent answer suggests this:

chrome --allow-file-access-from-files

Alternatively, you can try running a web server locally, or uploading the project to an actual web server.

1
  • Thanks for your answer, it seems that the problem stems indeed from the fact that i currently operate the page locally and Chrome doesn't like accessing local files for some reason. I will upload the finished page to a web server (my college's), I will post the results here.
    – Marius_O
    Commented Jul 21, 2015 at 19:24
0

OK Guys and Girls,

I think toms pretty much nailed the problem. The site was running locally on my PC, i edited the html,css and javascript with an editor and opened the html dircetly in the browser.

Only Firefox displayed the zipped shapefile.

The problem seems to stem from the fact that only Firefox allows locally hosted files, which took me quite a while to realize since I don't use any other browser and am pretty much inexperienced with developing web stuff.

Now I installed XAMPP (https://www.apachefriends.org/de/index.html) to quickly set up a local server for testing and loaded the site onto it. Both IE and Chrome now display the file correctly, which seems to prove the theory suggested by toms.

Many thanks to you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.