<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hii<br>I am trying to create a Dynamic SLD App using Geoserver + OpenLayers + Ajax<br>i
am trying with openlayers to read an sld file "the user will upload it
to the server" and i am sending a request with Ajax to retrieve .sld
file contents and it works fine till now.<br>the problem is that the map is not appearing although the sld contents retrieved in a good manner .<br>this is my javascript code :<br><script><br> function Send_Req(str){<br> if (str=="")<br> {<br> document.getElementById("map").innerHTML="";<br> return;<br> }<br> if (window.XMLHttpRequest)<br> {// code for IE7+, Firefox, Chrome, Opera, Safari<br> xmlhttp=new XMLHttpRequest();<br> }<br> else<br>
{// code for IE6, IE5<br> xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<br> }<br> xmlhttp.onreadystatechange=function()<br> {<br> if (xmlhttp.readyState==4 && xmlhttp.status==200)<br> {<br> var map;<br> var untiled;<br> var tiled;<br> var pureCoverage = false;<br> OpenLayers.DOTS_PER_INCH = 25.4 /
0.28;<br> OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;<br> OpenLayers.Util.onImageLoadErrorColor = "transparent"; <br> format = 'image/png';<br> if(pureCoverage) {<br> document.getElementById('filterType').disabled = true;<br> document.getElementById('filter').disabled = true;<br> document.getElementById('antialiasSelector').disabled =
true;<br> document.getElementById('updateFilterButton').disabled = true;<br> document.getElementById('resetFilterButton').disabled = true;<br> document.getElementById('jpeg').selected = true;<br> format = "image/jpeg";<br> }<br> var bounds = new OpenLayers.Bounds( -142.152, -72.075,87.654,
103.162);<br> var options = {<br> controls: [],<br> maxExtent: bounds,<br> maxResolution: 0.8976796874999999,<br> projection: "EPSG:3273",<br> units: 'm'<br>
};<br> map = new OpenLayers.Map('map', options);<br> var sldco=xmlhttp.responseText;<br> alert("sldco ="+sldco);<br> <br> tiled = new OpenLayers.Layer.WMS(<br> "attr_based_polygon:sld_cookbook_polygon - Tiled", "http://localhost:8080/geoserver/attr_based_polygon/wms",<br>
{<br> LAYERS: 'attr_based_polygon:sld_cookbook_polygon',<br> SLD_BODY: sldco,<br> isBaseLayer: true,<br> format: format,<br> tiled:
!pureCoverage,<br> tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom<br> },<br> {<br> buffer: 0,<br> displayOutsideMaxExtent: true,<br> isBaseLayer:
true<br> } <br> );<br> <br> untiled = new OpenLayers.Layer.WMS(<br> "attr_based_polygon:sld_cookbook_polygon - Untiled", "http://localhost:8080/geoserver/attr_based_polygon/wms",<br> {<br> LAYERS:
'attr_based_polygon:sld_cookbook_polygon',<br> SLD_BODY: sldco,<br> format: format<br> },<br> {singleTile: true, ratio: 1} <br> );<br> map.addLayers([untiled,
tiled]);<br> map.zoomToExtent(bounds); <br> }<br> }<br> xmlhttp.open("GET","http://localhost/trial9.php?q="+str,true);<br> xmlhttp.send();<br>} <br></script><br></td></tr></table>