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 have several raster layers defined in mapfile:

   LAYER
     NAME "01"
     TYPE raster
     STATUS off
     OPACITY 30
     DATA "01.png"
  END

   LAYER
     NAME "02"
     TYPE raster
     STATUS off
     OPACITY 30
     DATA "02.png"
  END

   LAYER
     NAME "03"
     TYPE raster
     STATUS off
     OPACITY 30
     DATA "03.png"
  END

They are in .png format in raster folder on my server (data/www/project4/raster).

I need to insert button which will update my map with raster. First button is 01, and when I click on that button, raster should be rendered on my map. Also, I'm interested is there an option where I can click on some button just to open menu with three buttons which will lead rendering those rasters.

Thank you.

share|improve this question
    
you will have to look into mapscript mapserver.org/mapscript/index.html –  Giovanni Manghi Jun 10 '11 at 17:15
    
Can you be more specific please? I'm beginner with mapserver. –  againstflow Jun 10 '11 at 17:48
2  
If I understand you correctly, you want to be able to toggle layers on and off. Have you considered using OpenLayers as a client? It offers that kind of functionality by default so you don't have to do too much yourself. –  underdark Jun 10 '11 at 18:03
    
another framework that works on top of Mapserver is p.Mapper –  Giovanni Manghi Jun 10 '11 at 18:29

1 Answer 1

up vote 4 down vote accepted

Many ways to skin the cat.

One easy way is to first, change all your Layer entries to STATUS ON.

Then expose the whole thing as a WMS service. IMHO, the documentation makes it seem harder than what it is. You just need to add metadata entries for each LAYER entry like:

LAYER
  NAME "01_name"
  TYPE raster
  STATUS ON
  OPACITY 30
  DATA "01.png"
  METADATA
    'wms_title'        '01_name'
    'wms_srs'          'EPSG:900913 EPSG:4326'
    'wms_extent'       '-124.449431 32.496501 -114.113529 42.073017'
  END
END

LAYER
  NAME "02_name"
  TYPE raster
  STATUS ON
  OPACITY 30
  DATA "02.png"
  METADATA
    'wms_title'        '02_name'
    'wms_srs'          'EPSG:900913 EPSG:4326'
    'wms_extent'       '-124.449431 32.496501 -114.113529 42.073017'
  END
END

...

You get the picture. You also need to add metadata entry for the entire MAP like:

MAP
  ... #all your other map stuff
  WEB

    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/mnt/singledsk/tmp'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/mnt/singledsk/tmp'

    # WMS server settings
    METADATA
     'ows_enable_request'  '*'
     'ows_title'           'amigo_imagery'
     'ows_onlineresource'  'http://myserver.net/cgibin/mapservmap=/srv/mapserver/amigo_imagery.map'
     'ows_srs'             'EPSG:4326'
    END
 END
END

Then, assuming you are using OpenLayers, create individual layers for every layer you have specified in your WMS

var wms_layer1 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
              "http://myserver.net/cgibin/mapservmap=/srv/mapserver/amigo_imagery.map", 
              {layers: "01_name"});

var wms_layer2 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
              "http://myserver.net/cgibin/mapservmap=/srv/mapserver/amigo_imagery.map", 
              {layers: "02_name"});

and add them to the map. You will then be able to use openlayers to turn on or off as you see fit.

share|improve this answer

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.