Raruto / leaflet-kmz

A KMZ file loader for Leaflet Maps
GNU General Public License v3.0
48 stars 27 forks source link

Enable CORS #14

Closed JORGEMAL closed 4 years ago

JORGEMAL commented 4 years ago

Hi,

Can you provide a tip to enable CORS in order to use the files in your example (https://raruto.github.io/leaflet-kmz/examples/regions.kmz)?

I suppose that CORS must be enabled somewhere within your JavaScript code. Am I correct? (Somewhere between )

Regards, Jorge Maldonado

Raruto commented 4 years ago

Hi Jorge, you can try replacing these lines:

kmz.load('https://raruto.github.io/leaflet-kmz/examples/regions.kmz');
kmz.load('https://raruto.github.io/leaflet-kmz/examples/capitals.kmz');
kmz.load('https://raruto.github.io/leaflet-kmz/examples/globe.kmz');
kmz.load('https://raruto.github.io/leaflet-kmz/examples/etna.kmz');

with the following:

kmz.load('https://cors-anywhere.herokuapp.com/https://raruto.github.io/leaflet-kmz/examples/regions.kmz');
kmz.load('https://cors-anywhere.herokuapp.com/https://raruto.github.io/leaflet-kmz/examples/capitals.kmz');
kmz.load('https://cors-anywhere.herokuapp.com/https://raruto.github.io/leaflet-kmz/examples/globe.kmz');
kmz.load('https://cors-anywhere.herokuapp.com/https://raruto.github.io/leaflet-kmz/examples/etna.kmz');

If in trouble, try searching on stackoverflow.com

Have a nice day, Raruto