[OpenLayers-Users] SUM: OpenLayers, MapServer Map files and AGG

Bill Thoen bthoen at gisnet.com
Tue Aug 5 14:28:34 EDT 2008


Thanks to Arnd Wippermann who pointed out this snippet from the source 
code in Layer.js; this was the clue I needed!
> perhaps it's the default map_imagetype in OL for the MapServer request.
>  
>     DEFAULT_PARAMS: {
>         mode: "map",
>         map_imagetype: "png"
>     },
If you're use MapServer configured for AGG and you want to get those 
nice anti-aliased lines from OpenLayers too, you've first got to define 
an OUTPUTFORMAT section in your map file something like this:

  OUTPUTFORMAT
    NAME  'AGG'
    DRIVER  "AGG/PNG"
    MIMETYPE  "image/png"
    IMAGEMODE  RGB
    EXTENSION  "png"
  END

Then when you call OpenLayers.Layer.MapServer(), you have to override 
the default parameter map_imagetype and set it to whatever you set as 
'NAME' in your OUTPUTFORMAT section, as in the following example:

  var layer = new OpenLayers.Layer.MapServer( "World", 
"http://my_domain.com/cgi-bin/mapserv",
    {
       map_imagetype: 'AGG',
       layers: 'my_layer',
       map: '/var/www/html/my_mapfile.map',
    }, { singleTile: true, });

...and then you get a pretty map!

- Bill Thoen




More information about the Users mailing list