Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am relay new to webGIS and these days i trying to develop webmap using FOSS software. This is my codes of open layers 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? Pls help me.

share|improve this question
1  
I don't know how you first put your example together, but if you didn't know GeoServer Admin can generate an OpenLayers example of any layer for you through the Layer Preview page (v2.1.3 and possibly earlier, I've only used one version). You can then take what you want from the preview's source. By default the preview will only contain one layer (can be a layer group) but by playing with the URL you can view multiple layers –  tomfumb Apr 21 '12 at 20:18
add comment

1 Answer

up vote 3 down vote accepted

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)

share|improve this answer
    
Thanks.Really help full. "it not working" means map is not showing browser.I will try according to your answer –  sacprasanna Apr 22 '12 at 5:18
    
It works ,Thanks –  sacprasanna Apr 27 '12 at 2:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.