Free tools Windows power users keep installed
One-click scans. No signup required.
To capture Leaflet SVG paths as a PNG with PhantomJS 1.9, render the map in a page, wait until its layers and tiles are ready, then call page.render('map.png'). For a direct page screenshot, keep Leaflet’s default SVG renderer: PhantomJS renders the page through WebKit and can capture SVG and Canvas content. Switch paths to Canvas only if your export method rasterizes through Canvas, such as leaflet-image; in that case, use preferCanvas: true or set renderer: L.canvas() on the paths that need to appear.
The key distinction is between taking a screenshot of the whole rendered page and exporting map content through a Canvas-based library. Those methods have different rules for SVG paths, CORS, and HTML controls.
Choose the capture method before changing Leaflet’s renderer
Leaflet’s ordinary vector paths—such as polylines, polygons, and circles—use SVG by default in the documented 1.9.4 API. That is not a problem for PhantomJS page capture: PhantomJS’s WebKit-based page renderer can include SVG and Canvas elements in a screenshot. If you are using page.render() on the map page, you can usually leave the paths as SVG.
A Canvas exporter is a different pipeline. The leaflet-image library exports through Canvas, so paths that exist only as SVG will not automatically become Canvas drawings for that export. Configure the map or the relevant paths to use Canvas when using that kind of exporter.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
| Method | Vector rendering | Controls and HTML markers | Main constraints |
|---|---|---|---|
PhantomJS page screenshot with page.render() |
Can capture the page’s rendered SVG and Canvas. | Part of the page rendering, including visible HTML, subject to the capture viewport and crop. | Wait for the map to finish rendering; set the viewport and optional crop. |
Canvas export with leaflet-image |
Use Canvas-rendered paths, for example with preferCanvas or a layer renderer. |
HTML-only controls, legends, and L.divIcon markers are not rasterized by the exporter. |
Tile and marker images need to be CORS-compatible; export scope is not the whole page. |
These approaches should not be treated as interchangeable. Choose direct capture when the desired output is what the browser displays, including SVG and page elements. Choose a Canvas exporter when your application specifically needs a Canvas-generated map image and can accept its content and CORS limits.
Build a page with a correctly sized Leaflet map
The map needs a real, nonzero size before it can draw correctly. Give its container explicit dimensions, initialize the map, set its view, and add the vector layers before taking the screenshot. Here is a compact page setup using Leaflet’s SVG default:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<style>
html, body { margin: 0; }
#map { width: 1280px; height: 800px; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
var coords = [
[51.51, -0.12],
[51.505, -0.09],
[51.50, -0.06]
];
L.polyline(coords, { color: '#d22', weight: 5 }).addTo(map);
// Set this only after your own required layers and overlays are ready.
window.mapCaptureReady = false;
// Replace this simple example signal with your application's real readiness checks.
map.whenReady(function () {
window.setTimeout(function () {
window.mapCaptureReady = true;
}, 500);
});
</script>
</body>
</html>
The readiness signal above only waits for Leaflet’s map-ready event plus a short settling interval. It is an example, not proof that external tile requests, asynchronous data, custom overlays, or animations have completed. In your own page, set the signal only after the specific work that matters to the image is done. For a map without tiles or asynchronous content, fewer checks may be needed.
When the paths must use Canvas
If you are passing the map through a Canvas exporter, enable Canvas as the map’s preferred path renderer or assign it per path:
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
var map = L.map('map', { preferCanvas: true }).setView([51.505, -0.09], 13);
var line = L.polyline(coords, { renderer: L.canvas() }).addTo(map);
preferCanvas changes the default rendering backend for paths. A per-layer renderer option targets the path you create, which is useful when only selected vector layers need Canvas. Neither setting is required merely because the final file is PNG: direct PhantomJS screenshots can render SVG.
Do not confuse SVGOverlay with ordinary paths
L.SVGOverlay is a separate Leaflet layer type: it binds an SVG element to geographic bounds and is documented as extending ImageOverlay. That is different from an ordinary polyline or polygon, which Leaflet draws as a vector path using its SVG or Canvas renderer. For a direct page screenshot, both are rendered page content; for a Canvas export, confirm that the chosen exporter supports the particular content you need rather than assuming every SVG-related layer becomes a Canvas path.
Capture the rendered page with PhantomJS 1.9
Save the following as capture.js. It opens the map page, sets a 1280-by-800 viewport, waits for the page’s readiness signal, and writes a PNG. The example uses a bounded timeout so a broken page does not hang indefinitely; tune the limit to your environment. The page-ready signal, not an arbitrary delay alone, determines when this sample captures.
var page = require('webpage').create();
var system = require('system');
var url = system.args[1] || 'http://localhost/map.html';
var timeoutMs = 30000;
var finished = false;
page.viewportSize = { width: 1280, height: 800 };
function fail(message) {
if (finished) return;
finished = true;
console.log(message);
phantom.exit(1);
}
page.onError = function (message) {
console.log('Page JavaScript error: ' + message);
};
page.open(url, function (status) {
if (status !== 'success') {
fail('Page failed to load: ' + url);
return;
}
var started = Date.now();
var poll = window.setInterval(function () {
if (finished) {
window.clearInterval(poll);
return;
}
var ready = page.evaluate(function () {
return window.mapCaptureReady === true;
});
if (ready) {
window.clearInterval(poll);
finished = true;
page.render('map.png');
phantom.exit(0);
} else if (Date.now() - started > timeoutMs) {
window.clearInterval(poll);
fail('Timed out waiting for window.mapCaptureReady');
}
}, 100);
});
Run it with PhantomJS 1.9 and the page URL:
phantomjs capture.js http://localhost/map.html
Use a URL that PhantomJS can reach from the machine running it. For local files, a local HTTP server is often easier to reason about than a file: URL, particularly when the page loads scripts, stylesheets, or tiles from other origins. The sample writes map.png in the current working directory. Check the process exit status in automation: zero means the script reached its render step; a nonzero exit means it could not open the page or reach the readiness condition.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Set the output size or crop
viewportSize determines the browser viewport, which affects responsive layout and the visible area captured. Set it before opening the page so the map initializes against the intended screen dimensions. If you need only a rectangular portion, set clipRect before rendering:
page.clipRect = { top: 40, left: 80, width: 900, height: 600 };
page.render('map-crop.png');
The crop coordinates are relative to the page’s rendered viewport. Make sure the crop includes the map and any attribution or controls that must remain visible. A crop does not resize the map; adjust the viewport or map container separately when the map itself should have a different layout.
Wait for the actual content, not just page load
A successful page.open() callback means the page opened, but it does not necessarily mean every map tile, data-driven vector, overlay, font, or animation has reached the state you intend to capture. A fixed delay can help with a simple static page, but it is fragile: slow responses can outlast it, and fast pages waste time waiting.
Prefer an explicit signal set by the page after its own content is ready. For a tile-backed map, track tile completion as well as the vector/data work that populates paths. For example, your application can listen to the tile layer’s loading lifecycle and combine that with its own data-loaded flag before setting window.mapCaptureReady. If a marker image or custom overlay loads separately, include it in the same readiness condition. Avoid declaring readiness before adding the final paths or changing the map view.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
- Ensure the map container has its final dimensions before capture.
- Add the layers and set the view before signaling readiness.
- Wait for external tile and image requests relevant to the image.
- Account for animations or delayed UI that could change the frame after your signal.
- Use a timeout and log failures so automation does not silently save an incomplete image.
Use leaflet-image only when its Canvas limits fit
leaflet-image produces an export through Canvas. Tile and marker images must be served with CORS compatibility for the browser to draw them into a readable Canvas. A tile source that displays normally in the page can still cause a Canvas export problem if the required cross-origin permissions are missing.
The exporter does not rasterize HTML-based features such as L.divIcon, zoom controls, or legends. If those must appear in the PNG, direct page capture is a better match, or render those elements separately as part of a workflow designed to composite them. Switching path rendering to Canvas will not convert HTML into Canvas content.
For heavy vector data, Canvas is worth testing: Leaflet’s FAQ says switching from SVG to Canvas may help considerably, depending on the application and data. That is a conditional recommendation, not a guaranteed speed improvement; there are no benchmark figures established here. Compare the rendering result and performance using your own geometries and target environment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep basemap attribution and tile use in scope
PNG export does not remove the obligations associated with the map tiles. If the page uses OpenStreetMap tiles, Leaflet’s quick-start documentation says attribution is obligatory. Keep the required attribution visible in the captured output when applicable, and follow the relevant tile provider’s usage policy. Selecting a different tile provider is a separate deployment decision from choosing PhantomJS or Canvas for the screenshot.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesBest Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Troubleshoot missing paths, blank tiles, and wrong dimensions
| Symptom | Likely cause | What to check or change |
|---|---|---|
| Vector paths are missing in the PNG | The paths were added after capture, the map was not ready, or a Canvas exporter was asked to export SVG-only paths. | Confirm the paths are present before the readiness signal. For leaflet-image, use preferCanvas or set renderer: L.canvas() on the relevant paths. |
| Basemap is blank or incomplete | Tile URLs are unreachable, the capture starts before tiles load, or a Canvas export encounters a CORS restriction. | Check tile requests and wait for their completion. For a Canvas exporter, verify that the tile source permits the required cross-origin use. |
Controls, legends, or L.divIcon markers are absent |
They are HTML features excluded from leaflet-image’s Canvas rasterization. |
Use direct page capture when you need visible page elements in the screenshot. |
| The map is cropped, tiny, or the wrong size | The map container or PhantomJS viewport has unintended dimensions, or the clip rectangle cuts off the desired area. | Set the container dimensions and page.viewportSize; adjust clipRect only for a deliberate crop. |
| Capture is intermittently incomplete | A delay is shorter than variable tile or data load times, or readiness is signaled too early. | Use a page-owned readiness flag based on the actual layers and resources required for the image, with a timeout for failure handling. |
| Heavy vectors render slowly | A large set of geometries may be costly for the current rendering backend. | Test Canvas rendering for the paths and compare with SVG in the target workload; the result depends on the application and data. |
Or skip the browser setup
If the map page is reachable on the web, ScreenshotNeo can capture the rendered page through one API request. It is a screenshot API and MCP server for developers, made by Yorker Media. This route is separate from configuring a local PhantomJS 1.9 environment; it will not capture a page that only exists on your machine unless that page is made reachable to the service.
The example saves the returned image response as a WebP file, matching the provided request pattern. ScreenshotNeo supports PNG, JPEG, WebP, or PDF; use the service documentation for the applicable output options. ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/map.html -o map.webp
ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does PhantomJS 1.9 require Leaflet paths to use Canvas to save PNG?
No. Canvas is needed for a Canvas-based export pipeline, not for PhantomJS’s direct page screenshot of rendered SVG.
Will changing to Canvas include my Leaflet controls and HTML markers in leaflet-image output?
No. Canvas-rendered paths do not make HTML controls, legends, or L.divIcon elements part of leaflet-image’s Canvas rasterization.
Is the 1-second delay in a basic PhantomJS example enough for every map?
No. It is only a sequencing example. A page-owned readiness signal tied to the map’s actual layers is more dependable.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →

