Created
January 7, 2015 23:50
-
-
Save jhohlfeld/45315f480ec366bd8c8c to your computer and use it in GitHub Desktop.
Template and Router to save requests to mapbox using Iron:router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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