Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
}); 
share|improve this question
    
Looks like you are hitting this issue: stackoverflow.com/questions/7331997/… –  BradHards Jan 26 '13 at 1:44
    
I've been looking for a solution to this as well. Nothing as of yet. It seems to work in Firefox and IE10, but Chrome and earlier IE are not functional. –  BrianJBaldwin Oct 3 '13 at 22:27
    
See also here: stackoverflow.com/questions/14613726/… –  webrian Oct 4 '13 at 0:26
    
or here: stackoverflow.com/questions/1903959/… It is a JavaScript issue, not an OpenLayers one. –  webrian Oct 4 '13 at 0:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.