Question

I have modified this example (http://openlayers.org/dev/examples/wmc.html) with a pre-fill textarea which contain a full text wmc like this one http://geobretagne.fr/context/test_rpcu.wmc

But when i open the page and load the pre-fill textarea with the button (Read as a map) i got a "TypeError: layersContext is undefined" while the wmc is good ! If i don't pref-fill and copy the wmc it works, but if i pre-fill it give me the TypeError.

Any ideas ?

Was it helpful?

Solution

Can you try to create jsFiddle to show the problem?

I created a jsFiddle based on the example which you mention above.

This works for me with pre-filled text in the textarea.

You can have a look at my jsFiddle here.

http://jsfiddle.net/goldrydigital/54vsX/

The code is as follows:

(function ($) {

function init() {
try {
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});     
var text = document.getElementById("wmc").value;
var jsonFormat = new OpenLayers.Format.JSON();
var mapOptions = jsonFormat.read(OpenLayers.Util.getElement('mapOptions').value);
map = format.read(text, {map: mapOptions});

} catch(err) { document.getElementById("wmc").value = err; }

}

init();

})(jQuery);

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top