Zoom help

An Tay Nguy anguy at geoanalytic.com
Thu Mar 16 12:49:41 EST 2000


Hi Christian,

I can't share the java applet with you because I do not own the code.
However, I will give you an example of how you would go about doing so.

Require knowledge: HTML, javascript, java 1.1(for writing java applet)
///////////////////////////////////////////////////////////////////////
In your java applet:
///////////////////////////////////////////////////////////////////////
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.StringTokenizer;
import netscape.javascript.JSObject;

public class yourmap extends Applet
    implements MouseListener, MouseMotionListener
{
    int m_nMode = 2;  // for zooming

	... code skipped

    public void SetMapMode( int nMode )
    {
        m_nMode = nMode;
    }

    public int GetMapMode( )
    {
        return( m_nMode );
    }
    public void mouseClicked(MouseEvent mouseevent)
    {
        Point point = mouseevent.getPoint();
        int x = point.x;
        int y = point.y;

        try
        {
            if( m_nMode == 2 )  // Zoom mode
            {
                // This is the part that java is controling the html through
                // the javascript object
		    JSObject jsobject = new JSObject();
                jsobject = JSObject.getWindow(this);
                String s = "document.mapserver.imgxy.value=\""+ x +"
"+y+"\";";
                jsobject.eval(s);

                // If you like, this part will submit your form
                s = "window.Submit();";
                jsobject.eval( s );
                return;
            }
        }
        catch(Exception _ex)
        {
            // Do your error handling
            return;
        }
    }
	... code skipped
}
////////////////////////////////////////////////////////////////////////////
////////////
In your HTML
////////////////////////////////////////////////////////////////////////////
////////////

... code skipped
// This is how you would insert your java applet to your HTML

<applet codebase="/website/java/" code="yourmap.class" height="400"
name="Applet1" width="625" VIEWASTEXT MAYSCRIPT>
	<param NAME="foreground" VALUE="FFFFFF">
	<param NAME="image"
VALUE="http://Dell/GeoServer1/tmp/Alberta953080412352.gif">
	<param NAME="background" VALUE="008080">
	<param NAME="label" VALUE="This string was passed from the HTML host.">
	</applet>

// This is how you would setup a CGI request form
// Notice the hidden variables "imgxy" that I manipulate in my java code

<form method="GET" name="mapserver" action="/website/cgi-bin/mapserv.exe"
LANGUAGE="javascript">
<input type="hidden" name="imgxy" value="-1 -1">
<input type="hidden" name="imgbox" value="-1 -1 -1 -1">
<input type="hidden" name="imgext" value="-3807089.710241 2398821.208540
5510263.838363 11712615.992762">
<input type="hidden" name="map" value="/geo/vauxhall.map">
<input type="hidden" name="mode" value="browse">
<input type="hidden" name="zoom" value="3">
<input type="hidden" name="layers" value="Yukon NWT BC Sask Alberta">
<input type="hidden" name="qlayer" value="Township">
</form>

... code skipped
// javascript code inside your HTML pages.
<SCRIPT Language="javascript" >
// this is the part the javascript is controlling the java applet

function SetMode( n )
{
   document.Applet1.SetMapMode( n );
}
</SCRIPT>

... code skipped


I hope this will help you.  I am sure there are people in our mailing list
who
would be happy to share their actual implementation.

Cheers!!

An Tay Nguy


> -----Original Message-----
> From: owner-mapserver-users at lists.gis.umn.edu
> [mailto:owner-mapserver-users at lists.gis.umn.edu]On Behalf Of Christian
> Brunner
> Sent: Wednesday, March 15, 2000 6:01 PM
> To: anguy at geoanalytic.com; mapserver-users at lists.gis.umn.edu
> Subject: Re: Zoom help
>
>
> Hi An,
>
> I am also a newbie at UMN MapServer, I did ESRI MOIMS and SDE
> programming. I am
> interested in having a look at your Java applet for client side
> interacting,
> perhaps
> some other fellows from newsgroup are also.
>
> DO you share your knowledge...thanks in advance!
>
> Cheers
>
> Christian
>
> > >>> "An Tay Nguy" <anguy at geoanalytic.com> 03/15/00 11:02AM >>>
> > Hi everyone,
> >
> > I am a newbie to the world of MapServer.
> [snip]
> > In my html code, I have a java applet that set the variable
> > imgxy(mouseclick), imgbox(the area of zoom in pixel) and submit the map
>
> --
> Christian A. Brunner				phone: ++49 (0) 69-95403850
>




More information about the mapserver-users mailing list