Last active
April 4, 2021 03:29
-
-
Save nedSaf/41fb11d4413b2a307266 to your computer and use it in GitHub Desktop.
Adding Leaflet-image to Leaflet-angular-directive
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
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
GREEEEEEEEAAAAT! Really thanks man. Helped me a lot.
BTW: need to remove the "period: $scope.period.value," line from the code