[I'm classifying this as a bug because I think with sufficient documentation for the install, I could avoid it.]

Mapbuilder tells me "Loading Mapbuilder program," and I get the animation that comes from this source:

/sites/all/modules/mapbuilder/mapbuilder-src/lib/skin/default/images/Loading.gif

Here are my paths from config.xml, where I changed the values to the *-src directory, and the path to the widget XML file to where that file is actually located:

/public_html/sites/all/modules/mapbuilder/demo/demisWorldMap.xml
/public_html/sites/all/modules/mapbuilder/mapbuilder-src/lib/skin/default
/en/widgetText.xml

Here is the map tag in a blog post. (The behavior is the same whether the width/height/bbox attributes are present or not):

mapbuilder/config/6

The input format of the blog post is to mapbuilder.

And node 6 is as follows: (I know mapbuilder is looking at this, because an incorrect NID throws an error):

1. Title: This is a map configuration node

2. Model URL: /sites/all/modules/mapbuilder/demo/demisWorldMap.xml [Doesn't work without leading slash either]

The mapbuilder input format has been created. When I use these weights:

-10 expand mapbuilder tags
-9 HTML filter
10 Line break

My blog post with embedded map prints out: "This page requires Javascript to be enabled" and "Loading Mapbuilder program."

With this order I'm back to the perpetual load:

-10 HTML filter
-9 expand mapbuilder tags
10 Line break

What must I do, to get a map to load?

Drupal 5.1, PHP 5.2.1, FireFox 2.0.0.1

'./configure' '--enable-pic' '--with-apxs=/usr/local/apache/bin/apxs' '--with-libdir=lib64' '--prefix=/usr/local' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--enable-magic-quotes' '--with-mysqli' '--with-mysql=/usr' '--enable-discard-path' '--with-pear' '--enable-sockets' '--enable-track-vars' '--with-zlib'

P.S. JavaScript is enabled in my browser -- I get the little dragger bars in the post boxes, for instance.

However, I get this error (and others that I think cascade from it):

Error: this.node has no properties
Source File: http://www.universalpantograph.com/sites/all/modules/mapbuilder/mapbuild...
Line: 85

Help! I know nothing of JavaScript!

Comments

lambert-1’s picture

It looks like I've got a configuration with mapbuilder's JavaScript. From FF's error log:

Error: this.node has no properties.
Source File: ... all/modules/mapbuilder/mapbuilder-src/lib/widget/MapContainerBase.js

So, the good news is, the mapbuilder is finding the files. But it's not understanding them.

1. My $base_url is set in settings.php

2. Per the main Community Mapbuilder site, text/xml is a mime type:

# less mime.types |grep xml
application/xhtml+xml xhtml xht
application/xslt+xml xslt
application/xml xml xsl
application/xml-dtd dtd
application/xml-external-parsed-entity
text/xml
text/xml-external-parsed-entity

That's all I know to look for. What am I doing wrong?

PHP 5.2.1, curl and DOM installed, Drupal 5.1

jpulles’s picture

Assuming that in your browser source, you see that Mapbuilder loads a series of javascript files, it must be that your settings are ok.
I'm not happy how the mapbuilder module is performing under Drupal 5; sometimes the javascript loading returns errors such as you got. It improves when browser caching is enabled. At present I have no clue as to what causes this behaviour under drupal 5; drupal 4.x gives no problems.

jpulles’s picture

In my case, i often got the javascript error "Extent is not defined". The problem seems to be that not all javascript files are loaded in time. A workaround for this problem seemed a small addition to Mapbuilder.js, located in the lib folder of the Mapbuilder sources:

  this.setLoadState=function(newState){
    this.loadState=newState;
    switch (newState){
      case MB_LOAD_CORE:
        this.loadScript(baseDir+"/util/sarissa/Sarissa.js");
        ..
        // ADDITION: make sure that Extent.js is loaded in time
        this.loadScript(baseDir+"/tool/Extent.js");
        break;

After this patch, the map showed each time, even with browser caching disabled.

I hope this may help you?

lambert-1’s picture

openwereld:

I have caching enabled under Drupal 5.1 (not "aggressive," but normal).

And I really hate to rip out Drupal 4.1 and revert to 4.7.*

lambert-1’s picture

It sounds like I don't need to rip out and re-install Mapbuilder -- since the JS files are being understood. (That is, they wouldn't be throwing errors if they weren't being read).

Thanks for the ideas on a JavaScript patch but I have some questions:

1. Are you using the 1.0.1 stable release for the patch and for your testing or (as the config.xml file suggests) the 1.5 alpha? (I used 1.0.1)

2. How did you choose those two files (sarissa and extent) to load? From the errors that were thrown on your installation?

3. Do you have any other suggestions for me to test that my installation is installed and set up properly? Not to trash the documentation again, but for a lot of this, I was hoping I guessed right...

I'll try this and post my results...

jpulles’s picture

1) In general I use the stable 1.0.1 version of mapbuilder
2) I did not choose between Sarissa.js and Extent.js; the Extent.js file was added at the end of the list of javascript files which is already loaded by Mapbuilder in the MB_LOAD_CORE state. This one was added because of the javascript error ("Extent is not defined") and because the Extent.js file was the last file to load (as shown in the generated page source)
3) No more suggestions at this time. Javascript errors with Mapbuilder are often very difficult to solve. Sometimes you get javascript errors because the html doesn't contain the html elements which are referred to in the map config document.

lambert-1’s picture

My results:

I made the JavaScript change ("// ADDITION: make sure that Extent.js is loaded in time") and just got new errors of stuff that's not defined.

I'm going to rip out my installation and reinstall using the 1.5 alpha mapbuilder (since I surmise from your config.xml file, openwerel, that you are using that).

lambert-1’s picture

openwerel:

Javascript errors with Mapbuilder are often very difficult to solve. Sometimes you get javascript errors because the html doesn't contain the html elements which are referred to in the map config document

Huh? Couldn't you use XML schema to make sure undefine elements don't happen?

lambert-1’s picture

One more question, openwereld:
You write:

the Extent.js file was the last file to load (as shown in the generated page source)

Could you include the generated page source, so I can see what the page ought to have? Thanks.

lambert-1’s picture

Again, complete failure, after re-installing everything with the 1.0.1 mapbuilder library, and the suggested patch.

1. Submitted config node with demo context node (13) as per http://drupal.org/node/112157

2. Submitted blog node with mapbuilder input format on and the following HTML as per README.txt

<map>mapbuilder/config/15</map>

3. All I get is the animated "Loading mapbuilder" gif and the following error:

Error: this.node has no properties
Source File: http://www.universalpantograph.com/sites/all/modules/mapbuilder/mapbuilder-src/lib/widget/MapContainerBase.js
Line: 85

The settings:

1. config.xml:

<defaultModelUrl>/public_html/sites/all/modules/mapbuilder/demo/demisWorldMap.xml</defaultModelUrl>
<skinDir>/public_html/sites/all/modules/mapbuilder/mapbuilder-src/lib/skin/default</skinDir>

(The skinDir doesn't include "en," so I assume that's added automagically so the system can find widgetText.xml.)

2. admin/settings/mapbuilder:

Base: sites/all/modules/mapbuilder/mapbuilder-src/
Skin: sites/all/modules/mapbuilder/mapbuilder-src/lib/skin/default/

3. mapbuilder.module
<?PHP
// the path for contrib modules changes in drupal 5
if (!defined("VERSION") || floatval(VERSION) < 5) {
define("DEFAULT_MAPBUILDER_PATH", 'modules/mapbuilder/mapbuilder-src/');
} else {
define("DEFAULT_MAPBUILDER_PATH", 'sites/all/modules/mapbuilder/mapbuilder-src/');
}
?>

4. PHP5 with curl and xml. Drupal 5.1. FF 2.0.0.1. Here's the relevant HTML from the page build:

<script type="text/javascript">
  // URL of Mapbuilder configuration file.
  var mbConfigUrl="/mapbuilder/config/15";
  var baseDir="/sites/all/modules/mapbuilder/mapbuilder-src/lib";
  var language="en";
  
  // ruler?
</script>

<script type="text/javascript" src="/misc/jquery.js"></script>

<script type="text/javascript" src="/misc/drupal.js"></script>
<script type="text/javascript" src="/misc/textarea.js"></script>
<script type="text/javascript" src="/sites/all/modules/mapbuilder/mapbuilder-src/lib/Mapbuilder.js"></script>
<script type="text/javascript">
  function initOnLoad()
  {
    //alert( "init on load" );
  }

  function mapbuilderInitOnLoad()
  {
      mbDoLoad( initOnLoad );
  }

  if( Drupal.jsEnabled )
  {
    $(document).ready( mapbuilderInitOnLoad );
  }
</script>

Thanks for any help you can give.

jpulles’s picture

When looking at your page http://www.universalpantograph.com/node/15 in IE7 I got a javascript error for a DIV with ID="locatorContainer". This one is present in the config (see http://www.universalpantograph.com/mapbuilder/config/15) and will show an overview map if present. If you look for it in the mapbuilder.module file (or config.inc.php) you'll find a block in the function ..generate_config.. which is (true) by default. What happens if you change it to (false) so that it will not be written to the generated config file.

jpulles’s picture

I just got good results by changing the order of loading the drupal include files (jquery.js and drupal.js) and mapbuilder.js. If mapbuilder.js is loaded before these, the maps display consistently!
At this time, I don't want to rush committing this code to cvs, because there were some large changes in trying to support php4. A commit should follow this week.

In case you can't wait to try: the following code should replace the corresponding part in the mapbuilder_set_html_head function in mapbuilder.module...

        ...
        drupal_set_html_head($output);

        // include mapbuilder.js
        //drupal_add_js( config_path_to_url($mapbuilder_path . 'lib/Mapbuilder.js',TRUE),'file');
        
        // javascript code to initialize mapbuilder
        $output = '
  function initOnLoad()
  {
    //alert( "init on load" );
  }

  function mapbuilderInitOnLoad()
  {
      mbDoLoad( initOnLoad );
  }

  if( Drupal.jsEnabled )
  {
    $(document).ready( mapbuilderInitOnLoad );
  }
';
        drupal_add_js( $output, 'inline' );
        
        // add include file
        $output = "<script type=\"text/javascript\" src=\"".config_path_to_url($mapbuilder_path . 'lib/Mapbuilder.js')."\"></script>\n";
        drupal_set_html_head($output);
        
        $head_set = true;
        ...

This should have the effect that in the page source, mapbuilder.js is included before jquery/drupal.js.

lambert-1’s picture

Again, failure with FF 2.0.0.1. I made the change to the JavaScript. Here is what the HTML for the map node looks like:

<!-- begin content -->

<div id="node-14" class="node"><span class="submitted">Mon, 02/26/2007 - 02:40 &Ntilde; <a href="/user/xxx" title="View user profile.">xxx</a></span> 

<div class="content">
<div id="mainButtonBar_15"></div>

<div id="mainMapPane_15" class="c1"><noscript>This page requires Javascript to be enabled</noscript></div>
<div id="loading_15">
<p>Loading Mapbuilder program<br>
<br>
 <img alt="" src="/sites/all/modules/mapbuilder/mapbuilder-src/lib/skin/default/images/Loading.gif"></p>
</div>

<div id="legend_15"></div>

<div id="featureInfo"></div>

<p>1 2 3</p>
</div>

<div class="clear-block clear">
<ul class="links inline">
<li class="first blog_usernames_blog">
<a href="/blog/xxx" title="Read xxx's latest blog entries." class= "blog_usernames_blog">xxx's blog</a></li>
<li class="last comment_add"><a href="/comment/reply/14#comment_form" title="Share your thoughts and opinions related to this posting."
class="comment_add">Add new comment</a></li>
</ul>
</div>
</div>

<div id="comments"></div>

<!-- end content -->

There is no DIV with id=locatorContainer.

And here is the block for mapbuilder_generate_config:

function mapbuilder_generate_config( $nid = 0, $arg = '', $vid = NULL ) {
  if ($nid == 'add') {
    // used during preview
    $node = new stdClass;
    $node->nid = $node->vid = 0;
    // use modelUrl from $_SESSION
    $node->modelUrl = $_SESSION['modelUrl'];
    unset($_SESSION['modelUrl']);
    //echo var_export($_POST,true);
    //return;
  }
  else {
    $node = node_load( $nid, $arg == 'revisions' && is_numeric($vid) ? $vid : NULL );
    if ($node === false || $node->type != 'mapconfig') {
      // todo: error message
      drupal_set_header( 'Content-Type: text/plain' );
      echo var_export($node,true);
      return;
    }
  }

What is the line I am supposed to patch, and how do I patch it?

Again, here is the error I am still getting in FF -- it's the same.

Error: this.node has no properties
Source File: http://www.universalpantograph.com/sites/all/modules/mapbuilder/mapbuilder-src/lib/widget/MapContainerBase.js
Line: 85

I do get HTML errors, but not the ones that you mention.

http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.universalpa...

Could you point me to a working installation, or post the HTML? Maybe that will help me find out what's going on. I keep thinking there's some JS config issue I'm missing (baseDir) but Drupal JS is supposed to work out of the box...

Good luck with PHP4 XML functions; they're a mess, as I'm sure you're finding out...

jpulles’s picture

The DIV with id="locatorContainer" can be made available by enabling the Map Overview block. Or you can put it yourself in your page body, if your filter permits

's.
jpulles’s picture

A demo page can be found at http://testversie.geodan.nl/demo/?q=node/1.

jpulles’s picture

Title: Perpetual "Loading Mapbuilder program" » "Loading Mapbuilder program" runs into mapbuilder javascript errors
Component: Documentation » Code
Assigned: Unassigned » jpulles
Status: Active » Fixed

Title changed to reflect javascript errors which are occurring in the loaded community mapbuilder code. The picture with 'loading mapbuilder program' is an animated gif and thus keeps on repeating itself.
Code has been committed that improves the loading order of javascript files under drupal 5.0.

lambert-1’s picture

Yes, this fix worked for me. Thank you. (I revised the installation and testing documentation that I wrote accordingly.)

Anonymous’s picture

Status: Fixed » Closed (fixed)