Closed oliverlloyd closed 10 years ago
Hi! Thank you for reporting this! :smile:
In fact, I've only tested it without iron-router because my current project doesn't need it. I'll try to reproduce the error and see what I can do to fix it.
Hi, I did some testing. If we have a template like this:
Template.Map.rendered = function () {
Mapbox.load();
Tracker.autorun(function () {
if (Mapbox.loaded()) {
L.mapbox.accessToken = TOKEN;
var map = L.mapbox.map('map', MAP_ID);
}
});
};
It will throw the error if you render this template two or more times. But if we execute Mapbox.load()
function only once by moving it outside the rendered function scope, it will work (it worked in my tests).
But now I made the function be idempotent. So, theoretically it doesn't matter how many times it's going to be called.
Can you test the current master branch? If it fixes your code, I'll release a new package version.
Works, both the master branch and simply moving the call out of the rendered callback.
I added some updated examples https://github.com/pauloborges/meteor-mapbox/pull/2.
Fixed by bc8c702 and b7d60a4.
I can get this working just fine for a simple page load but when the autorun gets triggered from navigating to and from another page I get:
Error: Map container is already initialized.
I can avoid this by using a
isMapInitialised
Session var but I was wondering if there might be a better approach? Indeed, have you been able to setup a fully reactive map?Great package though, thanks.