-
-
Notifications
You must be signed in to change notification settings - Fork 983
Closed
Description
maplibre-gl-js version: 1.15.2
Question
HI maplibre,
I have a task to capture high dpi map, and this is what I'm doing:
- Increase dpi
- Call map.resize();
- Wait for the resizing -> I choose to use "idle" event
- Capture the new map
Here's the code:
`
map.on('idle', function() {
console.log('A idle event occurred.');
});
function print() {
function afterIdled() {
map.off('idle', afterIdled);
var img = map.getCanvas().toDataURL("image/png");
var modal = document.getElementById("myModal");
var modalImg = document.getElementById("img01");
modal.style.display = "block";
modalImg.src = img;
setDPI(actualPixelRatio);
map.resize();
}
actualPixelRatio = window.devicePixelRatio;
setDPI(300 / 96);
map.on('idle', afterIdled);
var m = map.resize();
}
function setDPI(dpi) {
Object.defineProperty(window, "devicePixelRatio", {
get: function() {
return dpi;
}
});
}
`
I think it works fine, but with a big problem: I can't capture the credit (attribution)
Please take a look
So the question is:
- Is the "idle" event fit my requirement?
If "idle" event is fit, how can I capture the credit? Or I just need to capture image when the 2nd event is raised?
If "idle" event is not fit, please guide me another way.
Thanks,
Metadata
Metadata
Assignees
Labels
No labels

