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 form element with a reference to the mapplet applet as follows: 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. 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)