shramov / leaflet-plugins

Plugins for Leaflet library
http://psha.org.ru/b/leaflet-plugins.html
MIT License
722 stars 289 forks source link

Resolve local links #223

Closed Arsakes closed 8 years ago

Arsakes commented 8 years ago

If you put in local paths in href's in kml file, the library cannot read them proprley since it treats all urls the same way (as absolute paths/urls).

I.e if i put my doc.kml file in /data_files/doc.kml and doc.kml has field <href>a.png</href> field the library will try to load. /a.png instead /data_files/a.png

brunob commented 8 years ago

Yes, it's a browser limitation see #44 ;)

Arsakes commented 8 years ago

Well I've "fixed it". I simply modified to KML.js file to replace local paths (and only them) with base url of doc.kml + relative name. It works.

Edit: Plus I'm using node.js server so I'don't think this is related to the issue of local files in xmlhttprequest requests problem.

How exactly are requestes for urls referenced by main doc.kml resolved?

brunob commented 8 years ago

@Arsakes nice, maybe you can provide a pull request if you think your patch would be useful to others users ?

Arsakes commented 8 years ago

@brunob Yea, I could - but I think I need to dig deeper into it. It works - but now I'm not sure if this is really the way it supposed to work :)