- How do I install mastani/laravel-google-static-map in a Laravel app?
- Run composer require mastani/laravel-google-static-map, then publish the config file with php artisan vendor:publish and add your Google Maps API key to your .env file. Laravel auto-discovers the service provider and facade, so no manual registration is needed. There are no migrations, jobs, or storage steps involved.
- Does the package return an image file or just a URL?
- It builds a Google Static Maps URL string, not image bytes; you embed that URL in an img tag, email, or PDF. The image is fetched by whatever renders the URL, so the package itself makes no HTTP request or file write. If you need a saved file, download the URL server-side yourself and store the bytes.
- Which Laravel and PHP versions does v2.6 support?
- v2.6 adds Laravel 13.x support and earlier releases covered Laravel 8 and up, but confirm the exact illuminate/support constraint in composer.json before upgrading. Compatibility releases sometimes raise the upper bound and drop an older major, so check that your app's Laravel version is still inside the constraint. PHP 8.x is the practical baseline for recent Laravel versions.
- Can I add multiple markers, paths, and custom map styles?
- Yes. The fluent builder covers center, zoom, and size, and you can add markers, paths, custom map styles, map types, image formats, and scale options. That makes it suitable for styled thumbnails, route overlays, and multi-pin location maps.
- How do I embed a static map in a Laravel Mailable or PDF invoice?
- Build the map URL in your Mailable, controller, or PDF service and pass it to a Blade view as an img src. For PDFs and emails, the rendering service must be able to reach Google's servers, and your key restrictions must allow that request path. Keep dimensions and scale modest so the image stays small enough for email clients.
- Is my Google API key exposed when I put the map URL in HTML or email?
- Yes. Google Static Maps takes the API key as a query parameter, so any URL delivered to a browser, email client, or PDF renderer exposes that key. Use IP restrictions for purely server-side rendering, and treat client-rendered URLs as public. Referrer restrictions often break email and PDF rendering, so test your specific delivery path.
- Does it support signed Google Static Maps URLs?
- URL signing is not documented in the package overview, so verify it against the source before relying on it for a paid Google Maps plan. Google's digital signature protects premium-plan keys from URL tampering, and if the package does not add it you can append the signature yourself. Confirm with the maintainer or a quick source read.
- Can I cache or save the generated map images?
- The package only generates URLs, so any caching or saving is your responsibility. Google's terms require attribution and restrict permanent caching or re-hosting of static map images, so avoid treating generated maps as long-term assets. Short-lived thumbnail caches are the safer pattern; review the terms before storing images.
- Why is my static map broken or watermarked instead of throwing an error?
- Because the package only assembles a URL, invalid parameters usually show up as a broken image, a gray placeholder, or a watermark rather than an exception in your logs. Validate zoom, dimensions, marker syntax, and key restrictions locally, and assert the generated URL string in tests so regressions are caught without calling Google. Log the URL during development to compare it with Google's documented parameter rules.
- What are the alternatives to this package and when should I not use it?
- For non-Laravel services or very small use cases, a short helper that builds the Static Maps URL is often enough. For interactive maps use a JavaScript library, and for complex custom rendering a headless browser may be required. This package is the best fit when you want a Laravel facade, config-based key handling, and a fluent builder for emails, PDFs, and cached thumbnails.