[GIS] Getting OpenLayers Working in jsFiddle

openlayers-2

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.

Best Answer

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/

Related Question