1

Has anyone else noticed a problem getting OpenLayers to work within jsFiddle?

I can't see what's wrong with http://jsfiddle.net/dPdhZ/

or the others I've mentioned here:

https://stackoverflow.com/questions/10075862/trouble-getting-openlayers-examples-with-jquery-working-in-jsfiddle

But it's frustrating when they work fine as a static HTML document but not in a social, sharable format like jsFiddle.

EDIT: Don't assume that works and be cautious with using 100% widths/height on CSS for the map in jsFiddle.

3

Two things are missing in your example: a call to init (it's defined but not called) and some styling to make the map height larger than zero. Here's a working example: http://jsfiddle.net/a8kK4/

  • Thanks @Alex - this helped considerably. Two jsFiddle quirks though. 1) I don't know why init() wasn't already being called from the <body> tag. 2) If the height/width are set in CSS to 100% it doesn't doesn't always display. I am still baffled by jsfiddle.net/MS6Bn & jsfiddle.net/kPQfw but have managed (with your help) to get others working alright. – Mike Gifford Apr 10 '12 at 13:47
0

This is the way i do it. http://jsfiddle.net/FsAwY/

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • I played with this a bit jsfiddle.net/qn7Ks essentially to split it up a bit more into html, css & javascript. It is working there, partly because the init() isn't called in your script. Thanks though. Useful to have this example too. – Mike Gifford Apr 10 '12 at 14:00

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.