Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save epok07/40e7b5b0560a90e4de18d15c15be4b11 to your computer and use it in GitHub Desktop.
Save epok07/40e7b5b0560a90e4de18d15c15be4b11 to your computer and use it in GitHub Desktop.
Adding Leaflet-image to Leaflet-angular-directive
L_PREFER_CANVAS = true;
leafletData.getMap().then(function(map) {
leafletImage(map, function(err, canvas) {
var img = document.createElement('img');
var dimensions = map.getSize();
img.width = dimensions.x;
img.height = dimensions.y;
img.src = canvas.toDataURL();
var data = {
map: img.src,
period: $scope.period.value,
map_width: img.width,
map_height: img.height
// Here you can add this image to any element you want, or send it to the server for saving.
};
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment