地图的客户端是APPLET,当查询时总是先执行查询后做javascript控制语句
导致执行查询完毕loading图片才显示
这个时候已经不需要它了

解决方案 »

  1.   

    Detect if an Applet is ready
    <SCRIPT>
    function isAppletReady(a) {
       return a.isActive();
       } 
    </SCRIPT><FORM>
    <INPUT TYPE=button 
          VALUE="Check applet" 
         onClick="if (!isAppletReady(document.applets[0])) alert("not ready");" >
    </FORM>
     
    An Applet is ready when it's loaded and its init() method is done. 
    To execute a Javascript only when an Applet is ready : function waituntilok() {
       if (document.myApplet.isActive()) {
             doit();
             }
       else {
           settimeout(waituntilok(),5000)
           }
       }function doit() {
        ....
        }
      
    <BODY onLoad="waituntilok();">....</BODY>
     By calling the javascript function from the BODY onLoad handler, we can assume that the Applet is loaded, initiated and started. 
    Here a "browser friendly" solution from N. Witteman to check if an Applet can be loaded (or found). <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">onError = errHandler;  
      // Without he parentheses, because we don't want IE
      // to do this. Like this, only NS does.function appLoaded() {
     if (!document.applets[0].isActive)
        // in IE: isActive returns an error if the applet IS loaded, 
        // false if not loaded
        // in NS: isActive returns true if loaded, an error if not loaded, 
        // so never reaches the next statement
        alert("IE: Applet could not be loaded");
        }function errHandler() {
     alert("NS: Applet could not be loaded");
     consume();
     // stops further processing of the error
     }</SCRIPT>
    </HEAD><BODY onLoad = appLoaded();>
    <APPLET code=someClass.class
    codeBase=someURL height=50 width=300>
     
      

  2.   

    Display a page after all applets are loaded
    Place your page completely in a DIV tag. 
    Initially the visiable attribute is false. When the page is completely loaded, the DIV visibility attribute is set to to true. <HTML>
    <HEAD>
    <SCRIPT>
    function doIt() {
      if (document.all)
        mypage.style.visibility="visible"
      else
        document.mypage.visibility="visible" 
      }</SCRIPT></HEAD>
    <BODY onLoad="doIt();">
    <DIV name=mypage style="visibility:hidden" >
    ...
    </DIV>
    </BODY>
    </HTML> 
      

  3.   

    可先做一个小的applet,用它来显示“loading ...." 等信息。并且负责下载其它applet(你真正用到的applet)源代码如下:import java.applet.Applet;
    import java.applet.AppletStub;
    import java.awt.Graphics;
    import java.awt.GridLayout;
    import java.awt.Label;public class QuickLoader extends Applet implements Runnable,AppletStub
    {
      String appletToLoad;
      Label label;
      Thread appletThread;
      
      public void init()
      {
        appletToLoad=getParameter("applet");
        if(appletToLoad==null)
        {
          label=new Label("No applet to load.");
        }
        else
        {
          label=new Label("Please wait -- loading applet"+appletToLoad);
        }
        add(label);
      }  public void run()
      {
        if(appletToLoad==null)
          return;
        try
        {
          Class appletClass=Class.forName(appletToLoad);
          Applet realApplet=(Applet)appletClass.newInstance();
          realApplet.setStub(this);
          remove(label);
          setLayout(new GridLayout(1,0));
          add(realApplet);
          realApplet.init();
          realApplet.start();
        }
        catch(Exception e)
        {
          label.setText("Error loading applet.");
        }
        appletResize(400,35);
        validate();
      }
      public void start()
      {
        appletThread =new Thread(this);
        appletThread.start();
      }
      public void stop()
      {
        appletThread.stop();
        appletThread=null;
      }
      public void appletResize(int width,int height)
      {
        resize(width,height);
      }
    }将你要下载的applet的名字作为参数传递给QuickLoader.class就可以了
      

  4.   

    路人甲、顺子:
    现在的情况是APPLET早已经下载到客户端,当用户进行地图的放大、缩小、漫游、查询具体单位
    的时候,有一定的时间延迟,这个时间需要添加一个等待画面,就是所谓的loading一类的东东
    当定位到具体的地方的时候,这个等待画面消失。
    之前我用javascript做了一个。本想在查询之前visible,查询后hidden。可总是在地图已经定位好了后才显示等待画面。我考虑是因为优先级的问题。但不知道如何解决。
    鹤舞白沙,我心飞翔:可否将多线程讲的详细一点。
      

  5.   

    看有没有帮助To write an applet that shows a splashscreen, we need to know what happens when applets (and java classes in general) are loaded. 
    When you ask a java runtime to load a class (e.g. by giving it as a command-line argument to the java executable, or by loading a webpage containing an applet tag) the runtime tries to load that named class (e.g. "foo.class"). In general (as in this case), this can only complete once all the classes that foo depends on are also loaded. A class is dependant on any other class that: is a superclass of it. 
    is an interface that it implements, or a superinterface of any such interface. 
    that it explicitly references. 
    Most of these will, in general, be system classes (part of the browser) and thus can be loaded very quickly (if they're not already loaded) - but (for applets that consist of a number of classes) the "root" class isn't finished loading (and thus can't run) until all other classes that it references are also loaded - and they aren't loaded until any classes they reference are loaded (and so on). 
    So the reason that a big applet isn't able to do anything (like painting a "loading..." message) quickly is because the browser has to wait until all of the classes of the applet are downloaded. In order to have a "splashscreen" load quickly, and have it run before (and during) the loading of the rest of the applet, we have to break the explicit dependancy between the initial class and the other classes in the applet. The following example shows how to do this, and in the process shows off some of the amazing things you can do with the powerful java Classloader class. The example shows a tiny "loader" applet (initial.java) which serves to purposes: it displays the splash screen 
    it references the rest of the applet (by string), causing the remaining applet code to load. 
    The clever bit is that the loader doesn't explicitly reference the rest of the applet (in this case "second.java"), to the compiler doesn't pick this up as a dependancy - as far as it it concerned, initial is a freestanding class. Instead, initial references second programmatically, using the forName() method of class Class. Here's initial.java:     import java.awt.*;
        import java.applet.Applet;    public class initial extends Applet implements Runnable {
            private String classToLoad;        private void fetchClass(String className) {
                classToLoad = className;
                Thread t = new Thread(this);
                t.start();
            }
            
            public void run() {
                try {
                    Class mainClass = Class.forName(classToLoad);
                    Component mainInstance = 
                       (Component)mainClass.newInstance();
                    add(mainInstance);
                 }
                 catch (Exception e) {
                     e.printStackTrace();
                 }
            
                 invalidate();
                 validate();
             }
            
             /**
              *  Called when the applet is initialised -
              *  here we start the asynchronous load of the rest of
              *  the applet.
              */
             public void init() {                
                 setLayout(new BorderLayout());
                 fetchClass("second");
             }
            
             /**
              *  Display a simple message 
              */
             public void paint(Graphics g) {
                 g.drawString("loading...",30,30);
             }
        }And here's second.java, the source for our simple example second-phase: 
      import java.awt.*;  public class second extends Canvas {
         public void paint(Graphics g){
           Dimension d = getSize();
           g.setColor(Color.green);
           g.fillRect(0,0,d.width, d.height);
         }
      }You'll see from initial that it loads the subsequent code in a new thread - this is because Class.forName() blocks - if we didn't spawn a new thread then init() wouldn't terminate until second was loaded - and initial can't paint until its init() method exits. Here's the HTML code for loading the applet:   <h1>multi-stage applet<h1>
      <applet code=initial.class width=300 height=300>
      </applet>Notice that CODE points just to initial.class, not to subsequent classes like second.class - but the applet classloader will still need to be able to load second.class later, so it must be accessible, i.e. it must be in a place specified by the CODEBASE parameter. Now, ideally we'd have many classes in the second part, and the logical place to keep them would be a JAR file, but we can't name that JAR file in the applet's ARCHIVE parameter, as the applet environment always loads all the JARs mentioned in the ARCHIVE parameter, even if they don't appear to be referenced initially. Thus we're stuck loading individual classfiles across the network
      

  6.   

    路人兄:
    http://www.go2map.com/mappage/citypage/mappage.asp?DestGeoset=沈阳!!HirerID==go2map
    每当操作时左下角的东西如何实现? 
    http://www.online.tj.cn/
    这个网址的电子地图是如何实现的信息提示.
    右侧拉动放大缩小如何实现呢 
      

  7.   

    他用到mapinfo的产品
    http://dynamo.mapinfo.com/miproducts/Overview.cfm?productid=1162
      

  8.   

    路仁兄:
    那的确是MAPINFO的产品,是方正数码的MAPINFO中间件。
    我正开发类似的东西电子地图网站,但没有他们的中间件,自己做
    所以想弄个类似loading的提示,为的是不要让人家等的不耐烦而已