Mapplet: Java Client Extention for MapServer

Overview: The mapplet is a simple java applet to add "rubberband" box
zoom and query capabilities to MapServer applications. It uses Netscape
LiveConnect for applet/javascript communication. Netscape Navigator 3.0+
and MSIE 4.0+ are known to support it.

Installation: Copy the class files (mapplet.class and evalThread.class)
to your website someplace. Add the following two functions to your application
(eg. template files):

function mapplet_apply(name, minx, miny, maxx, maxy, redraw) {
  document.mapserv.imgbox.value = minx + " " + miny + " " + maxx + " " + maxy;
  document.mapserv.imgxy.value = minx + " " + miny;
}

function mapplet_error(message) {
  alert(message);
}

The function mapplet_apply allows the applet to pass it's information to
javascript. The version shown above demonstrates minimal use and assumes that
your main form name is "mapserv". The mapplet_error
function allows the applet to pass error messages to javascript. Both functions
must be present, and defined as above. Mapplet_apply parameters are:

  name - name of the calling applet
  
  minx, miny, maxx, maxy - coordinates of the box (or point) defined by the user
  
  redraw - a boolean flag that indicates whether a new map should be created (useful
  in LandView (http://maps.dnr.state.mn.us/landview) like applications that respond
  automatically to user actions  
  
Now replace a normal <input type="image"...> form element with a reference to the
mapplet applet as follows:

  <applet codebase="//java/mapplet" code="mapplet.class" width="300" height="400" name="mapplet" MAYSCRIPT>
    <param name="image" value="http://myhost/image.gif">
    <param name="jitter" value="10">
    <param name="thickness" value="2">
    <param name="color" value="yellow">
  </applet>

Applet parameters are:

  image - fully qualified url for the image, in a template use http://[host]:[port][img]
  color - color of the rectangle- by name, RGB triplet or hex (#ffffff), default is red
  thickness - thickness of the rectangle in pixels, default is 1
  jitter - minimum rect size, helps control poor mouse clicking

Lastly, add a couple of hidden variables to your form to hold applet data.

  <input type="hidden" name="imgxy" value="300 300">
  <input type="hidden" name="imgbox" value="-1 -1 -1 -1">

Imgxy represents a single mouse click and is used in lieu of a form image. It's
initial value should be the absoulte center of your image. This can be calculated 
using x = (cols-1)/2 and y = (rows-1)/2. Decimals (i.e. 199.5) are fine.

Copyright 2000. State of Minnesota - Department of Natural Resources

Written by Stephen Lime (steve.lime@dnr.state.mn.us)