Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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'}, 
if(!map.getCenter()){ map.zoomToMaxExtent(); } } 

<body onload='init();'>
    <div id='map_element' style='width: 500px; height: 500px;'>

What is the problem? Pls help me.

share|improve this question
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
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

Your Answer


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.