Recently I posted this question KML file seems to load in Openlayers without error but doesn't show vectors because I was having trouble getting KML vector data to show up. After searching around a bit it seems there is an issue with loading KML files locally.

I am developing a stand alone Application that will run on the desktop or on IOS. I am running openlayers via a WebKit view. I am loading my openlayers page from the local file system witch is part of the applications files when it's installed.

My guess is there is some sort of issue loading local files. Is there a way around this? I would even consider converting all my KML files if needed. Ideally I would like to be able to point to either a local file or a remote kml file and load it.

Here is the code I am using. It's from the Openlayers kml example that's online. The only difference is I am trying to load locally without running the html page on any sort of server.

var map = new OpenLayers.Map({
    div: "map",
    layers: [
        new OpenLayers.Layer.WMS(
            "WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
            {layers: "basic"}
        new OpenLayers.Layer.Vector("KML", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "kml-files/lines.kml",
                format: new OpenLayers.Format.KML({
                    extractStyles: true, 
                    extractAttributes: true,
                    maxDepth: 2
    center: new OpenLayers.LonLat(-112.169, 36.099),
    zoom: 11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.