Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium when you need a picture of the Google Maps view as it is rendered in a browser—its current center, zoom, controls, labels, overlays, and surrounding interface. Use the Google Maps Static API when you only need an image generated from known parameters such as center, zoom, size, and markers. Selenium captures browser state; Static API constructs an image request without JavaScript or dynamic page loading. The right choice depends on whether the browser experience itself is part of the output.

Choose the capture method first

Need Selenium browser screenshot Google Maps Static API
Capture the live rendered browser state Suitable: WebDriver captures the current browsing context or a selected element. Not its documented purpose; it creates an image from request parameters.
JavaScript and browser session Required for a browser-rendered Maps JavaScript view. No JavaScript or dynamic page loading is required.
Setup Compatible browser, Selenium WebDriver, a map page, and an application-specific readiness check. Enabled Maps Static API, a Google Cloud project with billing, credentials, and documented request parameters.
Output handling A screenshot file or image data returned by WebDriver. A Google-served API image; Google says not to store and serve copies from your own site.
Cost and quota Selenium is browser automation. Any Google API used by the page can still have its own terms and usage costs. Subject to current Maps Platform quotas and pricing; verify the settings for your project and billing region.

There is no documented benchmark proving that one method is always faster or cheaper. Select based on the required output and the permitted way you will distribute it.

Capture a rendered map with Selenium

Prerequisites

  • Python 3 and the Selenium package (pip install selenium).
  • A browser supported by your Selenium installation, such as current Chrome or Firefox, and its matching WebDriver setup.
  • A map page that your account and application are allowed to access.
  • A deterministic way to set the desired center, zoom, overlays, and viewport in your own page or test fixture.

The Selenium documentation describes the screenshot operation as capturing the “current browsing context.” It also documents element screenshots and a WebDriver endpoint that returns Base64-encoded image data. Screenshot behavior, especially full-page behavior, depends on the browser and driver implementation, so do not assume identical output across browsers. See the Selenium WebDriver screenshot documentation.

Viewport screenshot in Python

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

MAP_URL = "https://your-site.example/maps"
OUTPUT = Path("map-viewport.png")

options = Options()
options.add_argument("--window-size=1440,900")
# options.add_argument("--headless=new")  # Enable for a server or CI runner.

driver = webdriver.Chrome(options=options)
try:
    driver.get(MAP_URL)

    # Replace this selector and condition with one owned by your application.
    # A visible container is only a starting point, not proof that map tiles
    # and overlays have finished drawing.
    WebDriverWait(driver, 30).until(
        lambda d: d.find_element(By.CSS_SELECTOR, "[data-map-ready='true']").is_displayed()
    )

    # Set center, zoom, and overlays before this point in your application.
    driver.save_screenshot(str(OUTPUT))
finally:
    driver.quit()

This is a general WebDriver recipe, not a Google-specific readiness selector. The data-map-ready condition must be implemented by your application or test page. If you do not control the page, wait for observable, application-specific evidence that the intended state is complete, then verify the resulting pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture only the map element

from selenium.webdriver.common.by import By

map_element = driver.find_element(By.CSS_SELECTOR, "#map")
map_element.screenshot("map-element.png")

Element capture avoids browser chrome and unrelated page content. Make the element’s dimensions explicit in CSS, and ensure it is in the viewport before capture. If the map is drawn in a canvas, the element screenshot captures the rendered canvas pixels, not the underlying geographic data.

Set browser state before taking the shot

  1. Navigate to the map route with driver.get().
  2. Set the map center and zoom through your page’s controls or JavaScript API.
  3. Apply markers, polygons, heatmaps, filters, and any selected basemap or overlay.
  4. Wait for an application-owned ready signal or another condition that proves the required state, rather than relying on an arbitrary sleep.
  5. Confirm the viewport size and device-pixel settings used by the test environment.
  6. Call save_screenshot() for the viewport or element.screenshot() for a specific map container.

The official Selenium page does not define a universal Google Maps tile-ready selector. Network-idle alone may also be insufficient because map rendering can continue after requests complete. A robust test can expose a ready flag only after your own map initialization, data layers, and visual state are complete.

Generate a parameter-driven image with Google Maps Static API

Static API requests return an image from URL parameters and do not require a JavaScript browser session. This is appropriate when the output can be described by documented parameters and does not need live controls, a user-selected state, or custom DOM content. Read the Maps Static API overview before implementing a request.

Project and credential setup

  1. Create or select a Google Cloud project.
  2. Enable the Maps Static API for that project.
  3. Attach a billing account as required by Google.
  4. Create and restrict authentication credentials appropriate to your deployment.
  5. Review current quotas, pricing, attribution, and terms for the project’s billing region.

Do not put an unrestricted key in public source code. Google’s Static API best practices require authentication and HTTPS for requests containing API keys or user data, state a maximum total request URL length of 16,384 characters, and recommend pairing an API key with a digital signature. See the digital signature guidance for signing details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Search+ For Google
  • google search
  • google map
  • google plus
  • youtube music
  • youtube

Build a request

A typical request includes the endpoint, key, image size, map center, zoom, and optional markers or paths. Construct and encode parameters with an HTTP client rather than concatenating unescaped user input. Keep the complete URL below Google’s documented 16,384-character limit.

from urllib.parse import urlencode
import requests

params = {
    "size": "800x500",
    "center": "40.7484,-73.9857",
    "zoom": "14",
    "maptype": "roadmap",
    "markers": "color:red|40.7484,-73.9857",
    "key": "YOUR_API_KEY",
}
url = "https://maps.googleapis.com/maps/api/staticmap?" + urlencode(params)
response = requests.get(url, timeout=30)
response.raise_for_status()
content_type = response.headers.get("content-type", "")
if not content_type.startswith("image/"):
    raise RuntimeError(f"Expected an image, received {content_type}")
with open("static-map.png", "wb") as output:
    output.write(response.content)

Use the exact parameters supported by the current Static API documentation. A successful HTTP response should still be checked for content type and image validity; authentication, quota, and parameter errors can otherwise be mistaken for a usable file.

Attribution, storage, and policy obligations

A screenshot does not erase Google Maps Platform obligations. The Maps JavaScript API policies require clear, legible attribution and describe restrictions on pre-fetching, caching, and storing content. Applications also need publicly accessible Terms of Use and a Privacy Policy incorporating Google’s terms and policy. Place IDs have a stated caching exception, but that does not make other map or place content freely cacheable.

Google’s Maps Platform FAQ says a website may not store and serve copies generated by Maps Static API. Its compliant pattern is to reference the API directly from the page or background so Google serves the image to the end user. Do not build a permanent image archive from Static API responses without confirming that your use is permitted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Maps For Google
  • get around with real-time traffic information

For interactive maps, the policy also addresses user-interaction results such as Place Names: do not capture or persist them for a different context outside the user session. Review the live terms applicable to your project before publishing or retaining images. A page at https://developers.google.com/maps/terms-20180207 identifies itself as last updated February 7, 2018 and refers to a later license agreement; treat it as historical context, not the controlling current agreement.

When Selenium is the better fit

  • You must show the exact viewport a user sees, including controls, a search result panel, custom HTML, or application overlays.
  • The map state is produced by user interaction or application logic that cannot be represented by Static API parameters.
  • You are testing visual regressions in your own map interface.
  • You need an element screenshot rather than a standalone map image.

When Static API is the better fit

  • You know the center, zoom, size, markers, and paths in advance.
  • You want an image request without starting a browser or executing JavaScript.
  • You do not need custom DOM, interactive controls, or transient browser state.
  • Your delivery model can comply with Google’s direct-reference and attribution requirements.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server when you need a clean capture of a map page rather than a hand-managed WebDriver session. It accepts the cookie or consent banner like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether it was billed. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Use the API documentation at https://screenshotneo.com/docs/ for authentication and options. A one-call image request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Replace the URL with your map page. ScreenshotNeo supports full-page captures with lazy images loaded, CSS-selector element shots, dark mode, 12 device presets or custom viewports, retina scale, custom CSS and JavaScript, clicks, selector or network-idle waits, blocked ads and requests, custom headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, PDFs, HTML/CSS-to-image, and an OpenAPI specification. Parameter names used by other screenshot APIs also work to ease migration.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is on every plan. Sign up for the free plan to try a map capture without configuring a browser driver.

Rank #4
Europe GPS Map 2027 for Garmin Devices on microSD
  • Latest version - updated June 2026 Locate hotels, restaurants and attractions Find points of interest and routes and turn-by-turn voice directions Plug & Play Operation Works with virtually ALL Garmin devices
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The screenshot is blank or shows a loading map

Cause: capture occurred before your map and overlays reached their final state. Fix: expose an application-owned ready flag, wait for it with an explicit timeout, and verify center and zoom before capture. Do not treat a fixed sleep as proof of readiness.

The map is cropped or the wrong size

Cause: viewport dimensions, device scale, or element CSS size differ between environments. Fix: set the window size before navigation, size the map container explicitly, and use element capture when page chrome is not wanted. Full-page output is implementation-dependent.

Static API returns an error instead of an image

Check that the API is enabled, billing is attached, the key is valid and restricted correctly, parameters are URL-encoded, and the request stays under 16,384 characters. Confirm current quota and pricing in Google Cloud.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Labels or attribution are missing

Do not crop away required notices or overlays. Preserve clear, legible attribution and follow the current Maps Platform policies for the context in which the image is displayed.

Best Value
WonVon 5 Inch Motorcycle Carplay GPS Navigation System with Apple Carplay and Android Auto Portable Screen with Dual Bluetooth, Navigation, Siri, Google Assistant(Not Inchluded TPMS)
  • Seamless Wireless CarPlay Experience: Stay fully connected with wireless CarPlay, enabling hands-free navigation, calls, music, and voice commands—perfect for urban riders and touring enthusiasts
  • Android Auto for Every Adventure: Streamlined Android Auto for motorcycle support offers real-time GPS, voice-activated control, Bluetooth sync, music streaming, and app access for safer rides
  • 5-Inch IPS Display Built for Riding: Crisp 5-inch IPS touchscreen with 854x480 resolution, anti-glare view, sunlight readability, glove-friendly operation, and night mode display designed for bikers
  • Bluetooth Stereo with Immersive Audio: Enjoy premium motorcycle stereo system with Bluetooth headset pairing, hands-free calls, stable signal, surround sound, and ride-safe voice clarity
  • Waterproof and Weatherproof Ruggedness: IP-rated rugged housing ensures rainproof durability, dust resistance, mud protection, secure mount stability, and reliable function in all conditions

Repeated requests are rejected or unexpectedly expensive

Inspect quota, billing, cache behavior, and request volume. Selenium itself does not define Google API pricing; the map implementation and Google project determine applicable usage. For Static API images, do not create a local copy-serving system that conflicts with Google’s FAQ.

Practical decision checklist

  • Need browser controls, custom HTML, or a user interaction? Choose Selenium.
  • Need only a parameterized map image? Choose Static API.
  • Need reliable readiness? Add an application-specific signal and test it in the target browser.
  • Need to publish or retain output? Check attribution, caching, direct-reference, privacy, and terms requirements first.
  • Need managed browser capture with cleanup and an AI-agent interface? Consider ScreenshotNeo.

FAQ

How do I save a Selenium screenshot as a PNG?

Call driver.save_screenshot("map.png") for the current browsing context, or call element.screenshot("map.png") for one element.

Can Static API reproduce an interactive browser screenshot?

No. It generates an image from request parameters and does not represent the live DOM, controls, or transient interaction state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does Selenium guarantee identical full-page images in every browser?

No. Selenium documents implementation-dependent screenshot behavior. Pin the browser and driver versions used for visual tests and validate the output you require.

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.