0

Based on this minimal example of Mapael (part of the relevant code is down here):

$('#refresh').on('click', function() {

        // Update some plots and areas attributes ...
        var updatedOptions = {'areas' : {}, 'plots' : {}};

        // add some new plots ...
        var newPlots = {
            "Dijon" : {
                latitude : 47.323056,
                longitude : 5.041944
            }
        }

        $(".mapcontainer").trigger('update', [updatedOptions, newPlots, [], {animDuration : 1000}]);
    });

I created this example page with an update trigger that works fine. Now I want to move this to my real application php page, and it doesn't work! Please take a look here.

The annoying part is that the console of my Browser doesn't show any errors! How can I debug this problem when I don't see any errors? Please assist!

If you require any additional information, please ask. Thanks for any efforts.

PS: Please ignore the bad styling that the script and css code is in body. I'll fix this once this issue is resolved. I don't think it's the issue, since the example page that works is exactly the same and doesn't have this problem.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189

1 Answers1

0

First, take a note that you're using different versions of Maphael:

  • on the page where it works, version is 1.1.0,
  • on your page it is 2.0.0-dev.

Second, after setting a breakpoint at the "onUpdateEvent" method of Maphael (line 876), it just seems that event data just doesn't get passed into the handler.

Does the "update" event have the same signature for Maphael/Raphael 1.x and 2.x? This is the place you should look at.

Update: I took a look at the 2.0.0-dev internals, and it seems your update code should be something like this:

var updatedOptions = {'areas': {}, 'plots' : {},
    // add some new plots ...
    newPlots: {
        "Dijon" : {
            latitude : 47.323056,
            longitude : 5.041944
        }
    },
    animDuration : 1000
};

$(".mapcontainer").trigger('update', updatedOptions);

(last line may be:

$(".mapcontainer").trigger('update', [updatedOptions]);

)

Please check if it helps (though I'd recomment you to switch to a stable 1.1.0 release of Maphael).

Dmitriy Khudorozhkov
  • 1,624
  • 12
  • 24
  • Thanks a lot! I'll try downgrading now... I didn't realize the repo's master branch is version 2.0-dev... That's weird! – The Quantum Physicist Jun 04 '16 at 11:12
  • @TheQuantumPhysicist using master branch (instead of a separate branch) for development is usual for many projects, unfortunately. On Github, you should always go to "releases" page and download the latest stable one: https://github.com/neveldo/jQuery-Mapael/releases – Dmitriy Khudorozhkov Jun 04 '16 at 11:20
  • It worked after downgrading to 1.1.0 through the tag 1.1.0! Thank you very much! – The Quantum Physicist Jun 04 '16 at 11:26