[GIS] Why does GeoServer WMS not work in OpenLayers

geoserveropenlayers-2wms

I am really new to Web GIS and currently I am trying to develop a web map using FOSS software. This is my code of OpenLayers and it is not working.

GeoServer URL

http://localhost:8080/geoserver/sac/wms?service=WMS&version=1.1.0&request=GetMap&layers=sac:Luse&styles=&bbox=105097.8879663402,181965.81598811893,107146.57910105384,183739.10929816443&width=512&height=443&srs=EPSG:5235&format=application/openlayers&

OpenLayers code:

<script type='text/javascript' src='OpenLayers.js'>
</script><script type='text/javascript'> 
var map; function init() 
{ 
   map = new OpenLayers.Map('map_element', {}); 
   var wms = new OpenLayers.Layer.WMS( 'OpenLayers WMS', 'http://localhost:8080/geoserver/sac/wms', 
   {layers: 'sac:Luse'}, 
   {} 
); 
map.addLayer(wms); 
if(!map.getCenter()){ map.zoomToMaxExtent(); } } 
</script>
</head>
<body onload='init();'>
    <div id='map_element' style='width: 500px; height: 500px;'>
</div>
</body>
</html>

What is the problem?

Best Answer

It is better if you explain what do you mean by "it not working" but my guess would be : By default openlayers support EPSG:4326 projection. Here as I see you are requesting a layer in EPSG:5235 so you have to set projection explicitly to EPSG:5235.

It should be similar to this code :

var mapoptions = {
      maxExtent: new OpenLayers.Bounds(...),
      units: 'm',
      projection: "EPSG:5235",
    };
    map = new OpenLayers.Map( 'map',mapoptions );

There should be several documentation about the basics of openlayers (particularly about projections and bounds that might be tricky from time to time)