UPDATE simplified with JSFiddle example: here is the most simplistic JSFiddle showing what I mean: http://jsfiddle.net/eflowbeach/75eq1mqe/

You can see in Chrome and IE that the feature appears, in Firefox nothing displays. The KML is valid.

Original Question: Has anyone else had a KML vector layer display perfectly fine in Chrome (v35) and IE10+, but fails to add the features to the layer in Firefox (v30)? I'm using OpenLayers 2.12 and have also tested in 2.13.1 without success.

var test = new OpenLayers.Layer.Vector("test",
    projection : new OpenLayers.Projection("EPSG:4326"),
    strategies : [new OpenLayers.Strategy.Fixed()],
    protocol : new OpenLayers.Protocol.HTTP(
      url : "myFile.kml",
      format : new OpenLayers.Format.KML(
        extractStyles : true,
        extractAttributes : true 

When you look at the features of this layer in the console:


Chrome and IE have 11 features in Firefox the feature array is empty.

Here's the link to the KML file in question: https://drive.google.com/file/d/0B_iQDBiLH9cfQWIzS3A4anZqcVk/edit?usp=sharing

I've had this happen to other files too, so I was wondering if it was something wrong with my format statement.

  • If you run Firebug when doing this, are you getting any errors showing up?
    – Branco
    Jul 24 '14 at 11:49
  • @Branco no, Firebug does not fire any errors.
    – Jonathan
    Aug 15 '14 at 15:09

This might have to do with some browser security features in Firefox that block access to local files, that aren't present in chrome/IE. It might require using a proxy to make it look like it's from somewhere else, or a workaround to the local restriction. A few links below that might explain a bit better.

Blog post from a GIS developer who had a kml issue somewhat similar: http://reganbj.blogspot.ca/2009/10/mystery-solved.html

Summary of issue from Mozillazine, summarizing the basis for the problem: http://kb.mozillazine.org/Links_to_local_pages_do_not_work

Stack overflow questions relating to the issue (many other related Q's on overflow and superuser): https://stackoverflow.com/questions/192080/firefox-links-to-local-or-network-pages-do-not-work?rq=1 https://stackoverflow.com/questions/7331997/kml-layer-in-openlayers-doesnt-work-on-localhost?rq=1

  • These are good links and that may very well be what the issue is. I don't really want to have to have my users make modifications to their browser security settings, so I guess I'm a little stuck. That KML file is on my server and it seems that OpenLayers.Protocol.HTTP should be able to retrieve it without issues, but that doesn't appear to be the case. I'll award you the bounty for finding some good relevant information - thanks!
    – Jonathan
    Jul 25 '14 at 16:25
  • From what I've read, you might need to use a bit of server-side code, or external hosting for the file. the idea of a proxy server approach , suggested in the first link, to mimic an external source sounds like the easiest, and also indicated that if the javascript, html, and data are all in the same domain, the issue can be avoided
    – TDavis
    Jul 25 '14 at 16:44

Does it do this with all feature types or certain features? probins answer notes that in this bug lines work but points/icons aren't being displayed properly. Perhaps this can lead you in the right direction.

  • It seems to be all feature types.
    – Jonathan
    Jul 25 '14 at 12:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.