glitchr/ux-google
Composer 安装命令:
composer require glitchr/ux-google
包简介
Google API integration for Symfony
README 文档
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
Install dependencies:
npm installBuild 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:
- Ensure jQuery is loaded from CDN in your base template
- Configure Webpack to use external jQuery (see "jQuery Configuration" above)
- Don't import jQuery in your bootstrap.js or other entry files
License
LGPL-3.0-or-later
统计信息
- 总下载量: 180
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2022-11-24