Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Google Map Laravel Package

fungio/google-map

fungio/google-map is a PHP package for integrating Google Maps into Laravel/PHP applications, offering utilities to simplify map setup, markers, and location-based features.

View on GitHub
Deep Wiki
Context7

Getting Started

Install and confirm the package actually loads.

composer require fungio/google-map

Two things to verify before writing any code:

  1. The Composer name. The repo is fungio/fungio-google-map; check packagist.org for the published vendor/package name — if it isn't published, add a VCS repository entry to composer.json instead.
  2. Laravel auto-discovery. This package targets PHP 5.3+, which predates extra.laravel in composer.json. Assume no auto-discovery: if src/ contains a *ServiceProvider, register it manually in config/app.php (providers and, if present, aliases). If it doesn't, you just instantiate the classes directly.

Where to look first: the README example block, then src/. The surface area is small — expect a map class, a marker/lat-lng value object, and a render method that returns a <script> string for the Google Maps JS API v3. Read the render method before anything else; it tells you exactly what HTML/JS you're responsible for loading around it.

First use case — a contact page with one pin. Build the map in a controller, not in Blade:

// app/Http/Controllers/ContactController.php
public function show()
{
    $map = new Map();                 // verify class name in src/
    $map->setCenter(55.75, 37.61);    // lat, lng
    $map->setZoom(14);
    $map->addMarker(55.75, 37.61, 'Our office');

    return view('contact', ['mapHtml' => $map->render()]);
}
{{-- resources/views/contact.blade.php --}}
<div id="map" style="height:400px"></div>
{!! $mapHtml !!}

The double-brace vs. {!! !!} distinction here is not cosmetic — see Gotchas.

Implementation Patterns

Wrap it in your own factory. With 0 stars and 0 dependents, treat this package as a disposable dependency. Put a MapFactory or a small GoogleMap service behind a container binding so a future swap to @googlemaps/js-api-loader (or plain hand-written JS) touches one file:

// app/Services/MapFactory.php
class MapFactory
{
    public function make(float $lat, float $lng, int $zoom = 14)
    {
        $map = new \Fungio\GoogleMap\Map();
        $map->setCenter($lat, $lng);
        $map->setZoom($zoom);
        return $map;
    }
}

Pulling markers from Eloquent. This is the pattern you'll use most:

$map = app(MapFactory::class)->make(config('services.maps.center_lat'), config('services.maps.center_lng'));

Location::where('active', true)->each(function ($loc) use ($map) {
    $map->addMarker($loc->lat, $loc->lng, e($loc->name)); // escape user data here, not in Blade
});

Keep the API key in config, not in the map object. The package predates modern key handling, so you'll likely inject the key yourself when you emit the <script src="https://maps.googleapis.com/maps/api/js?key=..."> tag in your layout. Store it in config/services.php and reference config('services.maps.key') — never hardcode it in a Blade partial.

Multiple maps per page. Because the package emits raw JS, you'll get colliding initMap-style globals. Give each map a unique DOM id and a unique init function name, or append the rendered output inside an IIFE. A Blade component that takes a $mapId argument is the cleanest fix:

<x-google-map :html="$mapHtml" id="contact-map" />

Testing is cheap — assert on the string. No network calls are made; the package just builds text. So test the rendered output:

$html = app(MapFactory::class)->make(1.0, 2.0)->render();
$this->assertStringContainsString('new google.maps.Map', $html);
$this->assertStringContainsString('1', $html); // center coords present

That's the extent of what's worth testing. Don't try to assert marker visuals — that's Google's job.

Inertia / Livewire. This package produces a string of <script> markup that expects to run on page load. In a SPA-ish context, either render the map client-side with the official loader and skip this package entirely, or inject the script via x-html and manually trigger the init. For Livewire, wire:ignore on the map container is mandatory or the map gets destroyed on every re-render.

Gotchas and Tips

  • Unmaintained, and old enough to break on modern PHP. PHP 5.3-era code frequently contains ${var} string interpolation (deprecated in 8.2) and each()/create_function (removed in 8.0). Before adopting, grep -rn 'create_function\|each(' vendor/fungio/ and run the test suite on your PHP version. If it errors, fork it — you will not get an upstream fix at 0 stars.
  • Raw JS output must be unescaped, and that's an XSS surface. {!! $mapHtml !!} is required, but any marker label or info-window content you passed in is now executable markup. Escape at the point of addMarker(), not in the template.
  • Missing or wrong API key shows as a grey box. The failure mode is silent: no PHP exception, just a "For development purposes only" overlay or a console error. Check the browser console first, then Network — confirm the key= parameter is actually on the Maps JS request.
  • Double-loading the Maps JS API. If the package emits its own <script src=".../js"> and your layout already loads it, you'll get "You have included the Google Maps JavaScript API multiple times." Decide on one owner of that tag — ideally your layout, with async defer and a callback — and strip or ignore the package's.
  • No geocoding, no clustering, no directions. It's an API surface for placing markers on a map. Address→lat/lng requires a separate Geocoding API call; clusters and polylines you'll hand-write as raw JS appended after the rendered output. Once you need two of those, the wrapper stops earning its keep.
  • Debug with view-source, not the DOM inspector. Google Maps rewrites the container's DOM heavily; the element tree in DevTools tells you nothing about what the package emitted.
  • Extension points are thin. Subclass the map/marker classes or decorate the renderer to inject extra JS. Given the codebase size, patching the vendor file and committing the fork is a legitimate move here — just document it loudly, because composer update will silently revert it.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle