[OpenLayers-Users] map isn't appearing

moataz ahmed moataz_a7mad at yahoo.com
Sat Oct 22 04:27:06 EDT 2011


Hii
I am trying to create a Dynamic SLD App using Geoserver + OpenLayers + Ajax
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.
the problem is that the map is not appearing although the sld contents retrieved in a good manner .
this is my javascript code :
<script>
    function Send_Req(str){
        if (str=="")
      {
          document.getElementById("map").innerHTML="";
            return;
      }
        if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
                 xmlhttp=new XMLHttpRequest();
              }
        else
              {// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
    xmlhttp.onreadystatechange=function()
      {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var map;
            var untiled;
            var tiled;
            var pureCoverage = false;
            OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
            OpenLayers.Util.onImageLoadErrorColor = "transparent";    
              format = 'image/png';
             if(pureCoverage) {
                    document.getElementById('filterType').disabled = true;
                    document.getElementById('filter').disabled = true;
                    document.getElementById('antialiasSelector').disabled = true;
                    document.getElementById('updateFilterButton').disabled = true;
                    document.getElementById('resetFilterButton').disabled = true;
                    document.getElementById('jpeg').selected = true;
                    format = "image/jpeg";
                        }
                var bounds = new OpenLayers.Bounds( -142.152, -72.075,87.654, 103.162);
                var options = {
                    controls: [],
                    maxExtent: bounds,
                    maxResolution: 0.8976796874999999,
                    projection: "EPSG:3273",
                    units: 'm'
                    };
                map = new OpenLayers.Map('map', options);
                var sldco=xmlhttp.responseText;
                alert("sldco ="+sldco);
               
                tiled = new OpenLayers.Layer.WMS(
                    "attr_based_polygon:sld_cookbook_polygon - Tiled", "http://localhost:8080/geoserver/attr_based_polygon/wms",
                    {
                        LAYERS: 'attr_based_polygon:sld_cookbook_polygon',
                        SLD_BODY: sldco,
                        isBaseLayer: true,
                        format: format,
                        tiled: !pureCoverage,
                        tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
                    },
                    {
                        buffer: 0,
                        displayOutsideMaxExtent: true,
                        isBaseLayer: true
                    } 
                    );
                
                untiled = new OpenLayers.Layer.WMS(
                    "attr_based_polygon:sld_cookbook_polygon - Untiled", "http://localhost:8080/geoserver/attr_based_polygon/wms",
                    {
                        LAYERS: 'attr_based_polygon:sld_cookbook_polygon',
                        SLD_BODY: sldco,
                        format: format
                    },
                       {singleTile: true, ratio: 1} 
                    );
                    map.addLayers([untiled, tiled]);
                    map.zoomToExtent(bounds); 
                    }
              }
    xmlhttp.open("GET","http://localhost/trial9.php?q="+str,true);
    xmlhttp.send();
}                       
</script>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111022/1bf1cf5a/attachment-0001.html


More information about the Users mailing list