[Cartoweb-users] ToolTips addendum

Oliver Christen oliver.christen at camptocamp.com
Mon Feb 5 07:49:22 EST 2007


it seems you have the dreadfull "mainmap not defined" error
this will cause the whole tooltips javascript to not work, as you noticed.

to be more precise, the initialisation function of tooltips tries to access an object (mainmap) which is not ready yet. And then, later, when you try to pass the mouse on the map, it will throw the first error you reported in your mail.

you are using cartoweb 3.3? this problem was fixed in cartoweb cvs.
if you do not want to update your cartoweb, you can simply replace, in dhtmlcode.tpl

  {literal}
  function initToolTips() {
      if (typeof(AjaxPlugins.ToolTips) != 'undefined') {
        {/literal}
        AjaxPlugins.ToolTips.serviceUrl = '{$selfUrl}?toolTips=1';
        AjaxPlugins.ToolTips.charSet = '{$charset}';
        AjaxPlugins.ToolTips.lang = '{$toolTips_currentLanguage}';
        {literal}
      }

      // init the imagemap (area tags)
      if ($('map1')) {
          var imagemapTag = $('map1');
          xAppendChild(mainmap.getDisplay('map').rootDisplayLayer, imagemapTag); 
          AjaxPlugins.ToolTips.useMap();
      }
  }
  {/literal}

by

  {literal}
  function initToolTips() {
      if (typeof(AjaxPlugins.ToolTips) != 'undefined') {
        {/literal}
        AjaxPlugins.ToolTips.serviceUrl = '{$selfUrl}?toolTips=1';
        AjaxPlugins.ToolTips.charSet = '{$charset}';
        AjaxPlugins.ToolTips.lang = '{$toolTips_currentLanguage}';
        {literal}
      }

      // init the imagemap (area tags)
      if ($('map1')) {
          var imagemapTag = $('map1');
          args = new Array();
          args[0] = imagemapTag;
          checkMainmapExistence('callToolTips', args);
      }
  }

  /*
   * args is an array containing all the arguments passed originally
   */
  function callToolTips(args) {
    xAppendChild(mainmap.getDisplay('map').rootDisplayLayer, args[0]); 
    AjaxPlugins.ToolTips.useMap();
  }

  /*
   * generic loop function to wait till the mainmap object is ready
   * receive the name of the output function and an array containing the parameters to pass to this function
   */
  function checkMainmapExistence(functionCall, args) {
      try {
        mainmap
      } catch (e){
        setTimeout(function() { checkMainmapExistence(functionCall, args); }, 100);
        return;
      }
      // call to dynamically named function
      this[functionCall](args);
  }
  {/literal}

this will solve the first error.
let see if it will fix the second too :)

Oliver
  ----- Original Message ----- 
  From: Oliver Christen 
  To: frequens ; cartoweb-users at lists.maptools.org 
  Sent: Monday, February 05, 2007 12:32 PM
  Subject: Re: [Cartoweb-users] ToolTips addendum


  this seems to be triggered by one of the Event.observe(..) in the ToolTips.ajax.js
  i cant say which one as I dont have that error here.
  Could you add a few alert() in your ToolTips.ajax.js to see which one of the Event.observe(..)  trigger the error ?

  Oliver
    ----- Original Message ----- 
    From: frequens 
    To: cartoweb-users at lists.maptools.org 
    Sent: Monday, February 05, 2007 11:57 AM
    Subject: Re: [Cartoweb-users] ToolTips addendum





    On 2/5/07, Oliver Christen <oliver.christen at camptocamp.com> wrote: 
      the addEventListener error is strange.
      It is as if the object isnt available when IE try to use it.
      I had this kind of problem a few time with IE, but not when using tooltips.
      IE tries to access a property or object that hasnt been initialised yet.
      The easy way to find if that is the problem is to try on an old computer ^_^. It will work there because js will be handled more slowly.

    ....
      _observeAndCache: function(element, name, observer, useCapture) {
        if (!this.observers) this.observers = [];
        if (element.addEventListener) { ((((THE SCRIPT STOPS HERE)))) 
          this.observers.push([element, name, observer, useCapture]);
          element.addEventListener(name, observer, useCapture);
        } else if (element.attachEvent) {
          this.observers.push([element, name, observer, useCapture]);
          element.attachEvent('on' + name, observer);
        }
      },
    ......
     
    Yes, it is prototype.js, see up where the debugger complains



      Im not even sure where the error is triggered, as its not said in your error message :(
      Line 1727 seems to refer to prototype.js but as to why the error would be thrown there...

     


    The other two are from the ToolTipsAjax.js: 


    line 140
     mouseMove: function() {
            if (AjaxPlugins.ToolTips.isAjaxActive()) {
                clearTimeout( AjaxPlugins.ToolTips._timerMouseMove);
                AjaxPlugins.ToolTips._timerMouseMove = setTimeout(
                    "AjaxPlugins.ToolTips.checkMove()",
                    AjaxPlugins.ToolTips.toolTipsTimeout 
                );
                AjaxPlugins.ToolTips._result.hide(); (STOPS HERE)
            }
        },


    and 219 (220)

      sendRequest: function(argObject) {
            this.abortRequest();
            this._result.reset();  (STOPS HERE) 
            this._result.wait();

            var url = this.serviceUrl + '&' + this.buildQueryString(argObject);
            Logger.send('Request sent with url :' + url);
            this._ajaxRequest = new Ajax.Request (
                url,
                {method: 'get', onComplete: showResponse, onFailure: reportError}
            );

    Thank you for going this through,

    frequens



----------------------------------------------------------------------------


    _______________________________________________
    Cartoweb-users mailing list
    Cartoweb-users at lists.maptools.org
    http://lists.maptools.org/mailman/listinfo/cartoweb-users



------------------------------------------------------------------------------


  _______________________________________________
  Cartoweb-users mailing list
  Cartoweb-users at lists.maptools.org
  http://lists.maptools.org/mailman/listinfo/cartoweb-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20070205/2dfbcfc1/attachment.html


More information about the Cartoweb-users mailing list