mapbox / leaflet-omnivore

universal format parser for Leaflet & Mapbox.js
https://www.mapbox.com/mapbox.js/example/v1.0.0/omnivore-gpx/
Other
651 stars 126 forks source link

How to load a downloaded KML file into a map layer? #71

Closed majorbytes closed 8 years ago

majorbytes commented 8 years ago

I am trying to load a local KML file that I download. It does not seem to work. If I put the KML file in my www/ I can load it fine, but I cannot download to that dir when the app is running. I am downloading it into the /data/data/{APP DIRECTORY}/files/files/theKML.kml. I can read it with a file reader, but the ominivore will not load it up as a map layer..

tmcw commented 8 years ago

This question is better-suited for Stack Overflow: it sounds like you're trying to load an arbitrary file that isn't served by your web server, which is not possible.

majorbytes commented 8 years ago

This one will do it, but I would rather use Leaflet.. https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/KmlOverlay

map.addKmlOverlay() adds geographic markup onto the map from a KML file. You can specify the file using one of the following protocols: http, https, file, cdvfile or the file absolute path. Only Android, also accepts file:///android_asset/. The added overlays are clickable