Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To capture a Google Maps InfoWindow with html2canvas, create its content as a DOM element, open the InfoWindow, wait until its rendered node is visible and laid out, then pass that node to html2canvas. Export the resulting canvas as a PNG with toBlob() or toDataURL(). The important limitation is that html2canvas rebuilds an image from DOM and CSS; it does not take a native screenshot, and browser security rules can prevent some map imagery from appearing.
What you need before capturing an InfoWindow
This approach runs in a browser page that already has a Google Map and a marker. It also requires the Google Maps JavaScript API to be loaded and configured for your application, plus html2canvas installed or otherwise made available to the page. The InfoWindow content should be an element your application creates and controls.
Google Maps accepts an HTML element as InfoWindow content and lets code open the window on a map or anchor marker. See the Google Maps InfoWindow guide and InfoWindow reference. html2canvas accepts a DOM element as its capture target and supports PNG export; see the html2canvas examples.
Capture the InfoWindow content as a PNG
The following example assumes map and marker are already initialized. It creates application-owned content, opens an InfoWindow, waits for the window’s documented visibility event, and then captures the content element. The event avoids guessing with a fixed sleep, which can be too short on a slow device and unnecessarily long on a fast one.
#1 Best Overall
import html2canvas from 'html2canvas';
const content = document.createElement('div');
content.className = 'capture-infowindow';
content.innerHTML = `
<h2>Place name</h2>
<p>Details shown in the InfoWindow.</p>
`;
const infoWindow = new google.maps.InfoWindow({
content,
maxWidth: 320,
});
function waitForVisible(infoWindow) {
return new Promise((resolve) => {
const listener = infoWindow.addListener('visible', () => {
listener.remove();
resolve();
});
});
}
async function captureInfoWindow() {
const visible = waitForVisible(infoWindow);
infoWindow.open({ map, anchor: marker, shouldFocus: false });
await visible;
// Capture the application-owned content rather than Maps' private bubble.
const canvas = await html2canvas(content, {
backgroundColor: '#fff',
scale: window.devicePixelRatio,
useCORS: true,
});
const blob = await new Promise((resolve, reject) => {
canvas.toBlob((result) => {
if (result) resolve(result);
else reject(new Error('PNG export returned no data'));
}, 'image/png');
});
const link = document.createElement('a');
const objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
link.download = 'infowindow.png';
link.click();
URL.revokeObjectURL(objectUrl);
}
captureInfoWindow().catch((error) => {
console.error('Could not capture the InfoWindow:', error);
});
The Maps API documents the visible event as firing when the InfoWindow is fully visible. Listening before calling open() prevents missing the event if rendering completes quickly. If your application reuses an InfoWindow that is already visible, arrange a fresh visibility wait for the next open or verify that the content is laid out before capturing.
The example sets useCORS: true for images whose servers permit cross-origin access. It does not grant access by itself: image servers must send appropriate CORS headers. A canvas export can fail or omit assets when security restrictions apply, so catch export errors in production.
Install and load html2canvas
In a bundled JavaScript project, install the package with your package manager, then use the import shown above. If your application loads html2canvas another way, use the library instance provided by that setup instead. The essential requirement is that the code calling html2canvas(content, options) runs in the page with the rendered InfoWindow.
Why this captures the content, not necessarily the whole bubble
The API-owned content element is a stable target for the place name and details your app supplied. The surrounding Google-rendered bubble includes its own layout and controls. Capturing the whole bubble by querying .gm-style-iw can include more of that presentation, but the selector is an implementation detail of the Maps-rendered DOM and may change. Inspect the current page DOM if you choose that route; do not treat the class as a permanent API contract.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Wait for rendering and choose the right target
Prefer the visibility event to a fixed timeout
InfoWindow.open() starts an overlay display process; a call immediately after it may run before the node has been rendered. Wait for the documented visibility signal, or verify that the intended target exists and has nonzero layout dimensions. A fixed setTimeout() is only a rough fallback because rendering time varies by device and page load.
If you need to target Maps’ rendered bubble, a guarded polling approach can wait for its node and layout. The class is private implementation detail, so keep this isolated and be prepared to update it if Maps changes its DOM:
function waitForRenderedBubble() {
return new Promise((resolve) => {
const check = () => {
const node = document.querySelector('.gm-style-iw');
if (node && node.getBoundingClientRect().width > 0) {
resolve(node);
return;
}
requestAnimationFrame(check);
};
check();
});
}
Use this only after opening the InfoWindow and preferably after its visibility signal. For routine capture of your own title and details, capturing the application-controlled content element is less coupled to Maps internals.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsControl wrapping and dimensions
InfoWindow dimensions follow their content. Set maxWidth on the InfoWindow or CSS width constraints on the content element when consistent line wrapping matters. The Maps guide explains the sizing behavior and explicit sizing options. Avoid setting a fixed height unless you want clipping or extra blank space; allow content to determine height when possible.
Rank #3
.capture-infowindow {
box-sizing: border-box;
width: 300px;
padding: 12px;
color: #202124;
background: #fff;
font: 14px/1.45 Arial, sans-serif;
}
.capture-infowindow h2 {
margin: 0 0 8px;
font-size: 18px;
}
When you control the content element, style that element before opening the window so the map lays it out with the intended dimensions. If you need to exclude a close button or other control from an html2canvas capture, add data-html2canvas-ignore to the relevant node.
Set image quality, crop and viewport behavior
The default canvas dimensions generally follow the target’s on-page dimensions. For sharper output on a high-density display, use scale: window.devicePixelRatio, as in the example. This increases output pixel dimensions and memory use; for thumbnails or predictable file sizes, choose a smaller explicit scale such as 1.
html2canvas also provides crop and viewport configuration. The options x, y, width, and height define a capture region. windowWidth and windowHeight affect the virtual browser viewport used by rendering and can help when content is clipped due to viewport dimensions. Consult the html2canvas configuration reference for option definitions; test the exact dimensions with your layout, because changing the virtual viewport can affect wrapping and positioning.
Free tools Windows power users keep installed
One-click scans. No signup required.
If capturing a larger content wrapper that includes buttons, attribution, or other controls that should not appear, mark those nodes with data-html2canvas-ignore. This is often cleaner than cropping after rendering.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Understand map tiles, images and browser security
html2canvas reconstructs an image from the DOM and CSS it can inspect. It is not a browser compositor screenshot. Unsupported CSS may render differently, and cross-origin iframes cannot be rendered. A capture of only your InfoWindow content avoids many whole-map complications, but any external images inside that content can still be subject to cross-origin rules.
With useCORS: true, html2canvas attempts to load images in a CORS-enabled way. The image host must return an appropriate Access-Control-Allow-Origin header. If it does not, browser security prevents the canvas from safely exporting those pixels. A same-origin image proxy is an alternative when you are authorized to retrieve and serve those assets; it adds server work and you must respect the relevant site’s terms and access policies. html2canvas explains these constraints in its FAQ and getting started documentation.
Do not assume every Google basemap tile, marker image, or third-party asset will export. Test the exact map styling and assets in your application. If the requirement is a pixel-faithful image of everything visible on screen, a browser extension or operating-system screenshot captures displayed pixels differently from html2canvas, but that is outside this DOM-capture workflow.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot common capture failures
| Symptom | Likely cause | What to try |
|---|---|---|
| No element found or empty capture | The InfoWindow has not finished opening, or the query uses a Maps-internal class that is absent or changed. | Wait for the InfoWindow visible event. Prefer the content element your app created; if targeting the bubble, inspect the current DOM and confirm it has layout dimensions. |
| Text or layout differs from the visible window | html2canvas reconstructed DOM/CSS rather than taking a native screenshot; a style may be unsupported or fonts may not be ready. | Use supported, explicit CSS on the content element, keep the target focused, and verify the exact page styling in the output. |
| Images are missing | The image host may not allow CORS, or the asset may be inaccessible to the page. | Use useCORS: true only where the host sends suitable CORS headers. Otherwise serve an authorized copy through a same-origin proxy or omit the image. |
toDataURL() or toBlob() fails |
The canvas may be tainted by cross-origin content, or export may return no blob. | Catch the error and report capture failure. Fix the offending asset’s CORS path or remove it; do not assume html2canvas can bypass browser policy. |
| Output is clipped or wraps differently | The content width, target bounds, scale, or virtual viewport differs from the intended layout. | Constrain content width, inspect the target’s bounding box, then tune crop coordinates or viewport options and test the resulting dimensions. |
| Capture takes too long or uses excessive memory | A large target combined with high device-pixel scaling creates a large canvas. | Capture only the content wrapper, reduce scale, and avoid unnecessarily large crop dimensions. Browser canvas limits vary, so handle failed exports rather than relying on a fixed maximum. |
Alternative: capture a rendered page with ScreenshotNeo
If you need a server-side screenshot of a page showing a map and an open InfoWindow rather than a client-side DOM reconstruction, ScreenshotNeo is a website screenshot API and MCP server. A normal page screenshot captures the browser-rendered page, but it does not replace the targeted html2canvas approach when you need only the InfoWindow content element. Ensure your page opens the intended InfoWindow before the capture request.
Best Value
Or skip the browser setup:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://your-site.example/map-page
-o map-page.webp
See the ScreenshotNeo API documentation for request parameters. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture, and each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Every feature is on every plan. Sign up free for ScreenshotNeo.
Frequently Asked Questions
Can html2canvas capture the entire Google Map as well as the InfoWindow?
It can attempt a DOM/CSS reconstruction of a larger target, but cross-origin map assets and unsupported rendering can affect the result. Test the map tiles and styling used by your application; capturing only the InfoWindow content avoids many unrelated map assets.
Can I save the result as JPEG instead of PNG?
The canvas supports other export MIME types where the browser supports them. Use an appropriate MIME type with `toBlob()` or `toDataURL()` and account for the format’s transparency and quality behavior.
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.

