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.

I can't see why I am unable to replicate the KML Layer Example: http://openlayers.org/dev/examples/sundials.html

in jsFiddle: http://jsfiddle.net/JPN4C/

I'm assuming that it's the map protocol or something else near the url, but can't see what that is.

share|improve this question

1 Answer 1

In the first example the KML file exists locally. In the jsfiddle example the KML file exists on another server which presents a "cross-domain" security violation. The browser will not allow you to request that file unless you implement a proxyhost. Unfortunately you will not be able to make this example work on jsfiddle.

I suggest you just copy paste it into an html file. You get debugging, an example that works and a smile on your face :).

BTW can I ask what this whole jsFiddle craze is about? I noticed all your questions revolve around making these examples work on jsFiddle. That's fine in some cases, but you'll find you cannot run all openlayers examples on jsfiddle as they require you to have a local proxy which jsFiddle cannot provide.

Update:

Actually you could make it work if you're okay with storing the kml as a string variable in your page. Not requesting the KML from another server.

share|improve this answer
    
thanks. I'll see if I can replicate the KML as a string. As far as jsFiddle, it's partly a matter of being able to get my head around OpenLayers. There are nearly 200 examples, but they vary so much it's hard to address problems. By focusing on a few issues within jsFiddle it is easier to engage with folks like you and also share a working example that others can fork & extend. Ultimately I want this to work in Drupal 7's jQuery environment, but that's more specific than most folks need. I've also got plans to contribute accessibility fixes to OpenLayers & need a public test bed. –  Mike Gifford Apr 11 '12 at 17:04
    
Good to hear you want to contribute to OpenLayers code. FYI: you can get your own directory within the openlayers (sandbox)[dev.openlayers.org/sandbox/]. Let me know if you want me to update my answer with an example using the KML as a string. –  CaptDragon Apr 11 '12 at 17:19
    
Will do. Didn't realize about the sandbox. I've forked OpenLayers code here - github.com/mgifford/openlayers - but really, I'm not a Javascript developer. –  Mike Gifford Apr 11 '12 at 17:46
    
@CaptDragon wondering why the following fiddle works? This one also laods a KML file existing on another server jsfiddle.net/alangalan/hdGGF –  Alan David Garcia Jan 11 '13 at 17:12
    
@AlanDavidGarcia: The jsfiddle you present is using Google Maps API not OpenLayers. GoogleMaps approaches this differently. Basically they consume the KML on their servers and serve it out to the GoogleMaps application. More info here. –  CaptDragon Jan 11 '13 at 18:49

Your Answer

 
discard

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

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