MapServer TEMPLATE: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
Line 6: Line 6:
Without using a template, I (the masterful Web GIS progreammer) can create a .map file and put the appropriate URL onto a Web page, for example,
Without using a template, I (the masterful Web GIS progreammer) can create a .map file and put the appropriate URL onto a Web page, for example,


http://mapserver.wildsong.biz/cgi-bin/mapserv?map=../mapserver/html/demo/hello.map&mode=map&layer=credits
http://mapserver.wildsong.biz/cgi-bin/mapserv?map=../mapserver/html/demo/hello.map&layer=credits&mode=map


This invokes the CGI version of the mapserv executable that lives on my server
Reading the URL from left to right. this goes to my mapserver(http://mapserver.wildsong.biz/), invokes the mapserv executable (/cgi-bin/mapserv),
and tells it to load up a map file, display the results by sending the image  
telling it read a map file (map=../mapserver/html/demo/hello.map),
back to your browser ("mode=map"), and to display what's in the layer called credits ("layer=credits").
look for the 'credits' layer("layer=credits"),  
and finally to display the results by sending the image  
back to your browser ("mode=map").


I am keeping my files for this project in the html directory tree so that you can
I am keeping my files for this project in the html directory tree so that you can

Revision as of 23:20, 3 August 2005

"Templates" is the simplest way to create an interactive mapserver site. (You can create non-interactive ones without templates but what's the fun of that?)

The non-interacttive example

Without using a template, I (the masterful Web GIS progreammer) can create a .map file and put the appropriate URL onto a Web page, for example,

http://mapserver.wildsong.biz/cgi-bin/mapserv?map=../mapserver/html/demo/hello.map&layer=credits&mode=map

Reading the URL from left to right. this goes to my mapserver(http://mapserver.wildsong.biz/), invokes the mapserv executable (/cgi-bin/mapserv), telling it read a map file (map=../mapserver/html/demo/hello.map), look for the 'credits' layer("layer=credits"), and finally to display the results by sending the image back to your browser ("mode=map").

I am keeping my files for this project in the html directory tree so that you can download them if you want to look at them. For security normally I would keep them OUTSIDE the tree... just because...

So for example, you can grab the map file with this URL: http://mapserver.wildsong.biz/demo/hello.map

The first template

I walked through the MapServer template reference and created a template file that has most of the template tags in it. You can look at it; click here and do view source: http://mapserver.wildsong.biz/demo/hello.template.html

To get it to use my template file, I can change mode to browse and add a template specifier:

http://mapserver.wildsong.biz/cgi-bin/mapserv?map=../mapserver/html/demo/hello.map&mode=browse&map_web_template=../mapserver/html/demo/hello.template.html

I have to specify a layer; that example just shows you a blue box;

http://mapserver.wildsong.biz/cgi-bin/mapserv?map=../mapserver/html/demo/hello.map&mode=browse&map_web_template=../mapserver/html/demo/hello.template.html&layer=credits

The template has lots of mapserver template tags in it, which are a word enclosed by square brackets. They look like wiki tags, come to think of it.