Simple Recipes for the UMN Mapserver

Company Home

When I started using the UMN Mapserver , I found myself often looking for a simple example that illustrated just one concept, and was small enough that I could understand just one piece of Mapserver without having to plow through lots of code. These Mapserver Recipes are my attempt to improve that situation.

These examples are written using PHP/Mapscript. I assume you already have a working installation of Mapserver and PHP/Mapscript on your machine (although the first example can be used to find out whether you really do!).

Take special note that you will have to edit SHAPEPATH ,IMAGEPATH , and IMAGEURL in each .MAP file to match your own installation. If your web server is not configured to use PHP/Mapscript for .PHTML files, you'll have to reconfigure your server or rename the recipe files.

You can download all the the PHTML and MAP files at http://www.mobilegeographics.com/mapserver/MSrecipes.tar.gz , and then follow the links to download the data files from USGS. At the moment these are the examples:

  • Hello World . Draws text only, no data file required.
  • USA1, a simple outline map of the US.
  • USA1a. The same outline map as in USA1, but it has some simple modifications applied in the PHP file to create a different look than what was defined in the original USA1.MAP . Both examples use exactly the same .MAP file.
  • USA1b. Like USA1a, this example uses PHP to modify USA1.MAP , this time to demonstrate some different map projections.
  • USA2, a more complicated map with two US layers (states and timezones), a legend, and a scalebar.
  • USA3, a very simple raster file example.

Data layer download

EMACS mapserver mode

A basic .MAP file mode for GNU Emacs is available at http://www.mobilegeographics.com/mapserver/mapserver-mode.el It provides indentation and some keyword highlighting. It has been tested under GNU Emacs but not under Xemacs (although it should work just fine under either editor).

US National Atlas and Atlas of North America

The US Geological Survey distributes a large set of data layers for the United States, and a small set of data layers covering all of North America. I have created a couple of .MAP files to display a subset of these layers. These .MAP files would be a good start toward a basemap if your project covers regional scale areas in the USA or North America. These maps are certainly not finished products, but they will get you started. Where the screenshot files for the two different atlases show the same location, I have used identical map extent and projection, so that you can compare the detail of the two datasets.

To use these .MAP files in your own projects, you'll have to download the appropriate Shapefiles from USGS yourself, and edit the value of SHAPEPATH to match your installation. You'll also need to deal with the FONTSET and SYMBOLSET settings, and switch the fonts to BITMAP if you don't have TrueType fonts installed.

National Atlas of the United States data layer download: http://www.nationalatlas.gov/atlasftp.html

North American Atlas data layer download: http://www.nationalatlas.gov/atlasftp-na.html

These files are free for anyone to use, redistribute, modify, or republish. If you make improvements, please send them back to me so I can update the masters for everyone's benefit.