glitchr/ux-google

Google API integration for Symfony

Installs: 176

Dependents: 0

Suggesters: 0

Security: 0

Type:symfony-bundle

pkg:composer/glitchr/ux-google

1.0.x-dev 2026-02-17 03:03 UTC

This package is auto-updated.

Last update: 2026-02-17 03:04:19 UTC


README

Google Maps integration with html2canvas support for Symfony applications.

Requirements

  • jQuery 3.0+ must be loaded globally before this bundle's scripts
  • Symfony Webpack Encore for asset compilation

Installation

  1. Install dependencies:

    npm install
    
  2. Build assets:

    make assets APP_DEBUG=0
    # or
    npm run prod
    

jQuery Configuration

Important: This package expects jQuery to be available globally as window.jQuery and window.$.

In your main application

Make sure your webpack.config.js treats jQuery as an external dependency:

Encore
    .addExternals({
        jquery: 'jQuery'
    })

And load jQuery from CDN in your base template before loading this bundle's scripts:

<script src="https://code.jquery.com/jquery-3.6.2.min.js"></script>
<script src="/bundles/google/maps.js"></script>

Usage

In Twig templates:

{{ google_maps("myMap", {
    "html2canvas": true,
    "style": "height:400px; width:100%;"
}) }}

Export/Suppress buttons:

{{ google_maps_export("myMap", {
    "text": "Export"
}) }}

{{ google_maps_suppress("myMap", {
    "text": "×"
}) }}

jQuery Plugin API

The bundle provides a jQuery plugin for html2canvas:

$('#myMap').html2canvas('#myMap', {
    insert: 'prepend'
}, function(canvas) {
    // Callback when canvas is ready
    console.log('Canvas generated:', canvas);
});

Troubleshooting

$.fn.html2canvas is not a function

This error means jQuery was not loaded before maps.js, or jQuery is being replaced after maps.js loads.

Solution:

  1. Ensure jQuery is loaded from CDN in your base template
  2. Configure Webpack to use external jQuery (see "jQuery Configuration" above)
  3. Don't import jQuery in your bootstrap.js or other entry files

License

LGPL-3.0-or-later