Skip to content

Instantly share code, notes, and snippets.

@jhohlfeld
Created January 7, 2015 23:50
Show Gist options
  • Save jhohlfeld/45315f480ec366bd8c8c to your computer and use it in GitHub Desktop.
Save jhohlfeld/45315f480ec366bd8c8c to your computer and use it in GitHub Desktop.
Template and Router to save requests to mapbox using Iron:router
var map, map_canvas;
var MapController = RouteController.extend({
onStop: function() {
if(!map_canvas) {
return;
}
map_canvas.detach();
}
});
Template.map.rendered = function() {
this.autorun(function() {
if (!Meteor.polymerReady.get()) {
return;
}
if (!Mapbox.loaded()) {
console.log('loading mapbox');
Mapbox.load();
return;
}
if(!map) {
map_canvas = $('#map');
console.log('initializing mapbox');
L.mapbox.accessToken = '<api-key>';
map = L.mapbox.map(map_canvas[0], '<map-id>');
} else {
$('#map').replaceWith(map_canvas);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment