this shows a map as plain .html
- Code: Select all
<html>
<head>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
</script>
</body>
</html>
In servoy I store the following code in a form variable and use a function to pase the xml
- Code: Select all
var map = stripCDataTags(
<html>
<head>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
<![CDATA[
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
]]>
</script>
</body>
</html>);
function stripCDataTags(html) {
return html.toXMLString().replace(']]>', '').replace('<![CDATA[', '');
}
on my form I have a html area bound to this formvariable map.
In my solution nothing is shown. When I print the parsed code to the console it's altered and doesn't work on itself anymore
- Code: Select all
<html>
<head>
<script src="http://openlayers.org/api/OpenLayers.js"/>
</head>
<body>
<div id="map" style="width:100%; height:100%"/>
<script defer="defer" type="text/javascript">var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();</script>
</body>
</html>
when I paste the closing </script> back in in the head it works again (as plain html.
I can't figure out how to show my map. Is there somebody who has any idea how i can get this working?