4

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 
 })
 })
 });
 me.map.addLayer(test);

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

console.log(test[0].features);

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.

asked Jul 5, 2014 at 16:56
2
  • If you run Firebug when doing this, are you getting any errors showing up? Commented Jul 24, 2014 at 11:49
  • @Branco no, Firebug does not fire any errors. Commented Aug 15, 2014 at 15:09

2 Answers 2

1
+50

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

answered Jul 24, 2014 at 18:43
2
  • 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! Commented Jul 25, 2014 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 Commented Jul 25, 2014 at 16:44
0

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.

answered Jul 24, 2014 at 18:16
1
  • It seems to be all feature types. Commented Jul 25, 2014 at 12:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.