madj2k/t3-gadgeto-google
Composer 安装命令:
composer require madj2k/t3-gadgeto-google
包简介
Extension with Utilites and ViewHelper for accession Google API and Google Maps
README 文档
README
Gadgeto Google is a powerful TYPO3 extension that provides utilities for integrating the Google Geolocation API and Google Maps into your TYPO3 installation. It allows automatic geolocation of records, map display with filters, consent management, and full customization via Fluid templates.
🚀 Features
- Automatically fetches geolocation data (latitude/longitude) from the Google Geolocation API when a record is saved in the backend.
- Displays an interactive Google Map with:
- Address-based search functionality
- Filterable markers via categories
- Marker clustering to handle overlapping locations
- Clickable markers with custom detail overlays
- Ability to add custom overlays to highlight regions (e.g., specific countries)
- Fully customizable via Fluid templates
- Can be configured to use a single location as center of the map or show all definied locations at once
- List of all locations, hierarchically ordered by categories
- GDPR-compliant consent overlay for map loading
- Backend-ordered list of locations by category
- Extendable with your own models and repositories
- PageTS and TypoScript configuration for dynamic behavior
❗Breaking Changes
IMPORTANT - BREAKING CHANGES v13:
New template-structure. If you need to use the old templates, set the following TypoScript config via constants:
plugin.tx_gadgetogoogle {
view {
# cat=plugin.tx_gadgetogoogle/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:gadgeto_google/Resources/Private/v12/Templates/
# cat=plugin.tx_gadgetogoogle/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:gadgeto_google/Resources/Private/v12/Partials/
# cat=plugin.tx_gadgetogoogle/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:gadgeto_google/Resources/Private/v12/Layouts/
}
}
IMPORTANT - BREAKING CHANGES v12:
Add the following classes to your HTML elements:
js-gadgetogoogle-map-consent-btn: Consent button that enables the mapjs-gadgetogoogle-map-filter-btn: Filter buttons interacting with the map
📦 Installation
- Install the extension using the Extension Manager or Composer.
- Include the static TypoScript or use the provided page setup template.
- The extension requires
sjbr/static-info-tables. Import its tables through the Extension Manager to enable proper country support.
🔑 Google API Configuration
You need two separate Google API keys to use all features:
1. Geolocation API Key
Used to fetch coordinates based on addresses when saving a record in the backend.
- Required access: Geolocation API
- Restriction type: IP address (for backend security)
2. Maps JavaScript API Key
Used to render the map in the frontend.
- Required access: Maps JavaScript API
- Restriction type: HTTP referrer (frontend usage)
3. Google Maps ID
For enhanced styling and display behavior.
- Map type: JavaScript
- Style type: Raster map
More details:
⚙️ Extension Configuration
Go to System → Settings → Extension Configuration in the TYPO3 backend. Available global configuration options include:
apiHookTables
Comma-separated list of database tables that should trigger a call to the Google Geolocation API to populate latitude and longitude.
Ensure these tables have all necessary fields (see
ext_tables.sql, especiallytx_gadgetogoogle_domain_model_location).
defaultCountry
Defines a default/fallback country used when resolving address queries via the search bar. This value can be overridden in the plugin's FlexForm configuration.
removeFields
Specifies which fields of the location records should be hidden in the backend. Provide a comma-separated list of field names.
pluginsWithHeader
Controls which plugins display the "header" field in the backend form.
🛠 TypoScript Configuration
Place the following configuration into your TypoScript template to control frontend behavior:
plugin.tx_gadgetogoogle.settings {
maxSearchRadius = 10000
maxSearchDisplayRadius = 5000
defaultCountry = DE
}
These options control:
- maxSearchRadius: Maximum distance (in meters) for address-based search.
- maxSearchDisplayRadius: Maximum radius for displaying matching markers.
- defaultCountry: As above, sets default country code.
If you're using a proxy server, you can also configure cURL to respect proxy settings to allow external API requests.
🧩 FlexForm Customization via PageTS
To extend the available layout options in your plugin FlexForms:
// Important: You have to specifiy the extension-plugin (e.g. gadgetogoogle_map)
// AND the tab in the flexform (e.g. view) correctly
TCEFORM.tt_content.pi_flexform.gadgetogoogle_map.view.settings\.layout {
// add new option "List"
addItems.list = List
// Override label of existing option "default"
altLabels.default = Slot
// remove option "big"
removeItems = big
}
TCEFORM.tt_content.pi_flexform.gadgetogoogle_map.list.settings\.paginationStyle {
// remove option "More"
removeItems = More
}
TCEFORM.tt_content.pi_flexform.gadgetogoogle_map.list.settings\.listStyle {
// remove option "Category"
removeItems = Category
}
🎨 Category Style Customization via PageTS
To define selectable styles for categories:
TCEFORM.sys_category.tx_gadgetogoogle_style {
// add new option "Layout.1"
addItems.list = Layout-1
// Override label of existing option "default"
altLabels.default = Slot
// remove option "big"
removeItems = big
}
🧩 Restrict Selectable Categories via PageTS
To limit the category selection tree in the backend for locations:
TCEFORM.tx_gadgetogoogle_domain_model_location.categories {
config {
treeConfig {
startingPoints = 7 // parent category to start from
appearance.nonSelectableLevels = 0,1 // make root and parent-category not selectable
}
}
}
🔄 Integration Into Your Own Extensions
You can integrate the geolocation functionality into your custom extensions in two ways:
Option 1: Inheritance (Recommended)
Extend your model from the Location class provided by this extension. This gives you all geolocation logic out of the box.
👉 Learn how to extend Extbase models in TYPO3
Option 2: Trait + Interface
Implement \Gadgeto\GadgetoGoogle\Domain\FilterableInterface and use FilterableTrait in your model class.
⚠ You are responsible for:
- Defining required TCA and DB fields (see
TCA/tx_gadgetogoogle_domain_model_location.php)- Writing your own repositories
📍 Trigger Geolocation on Record Save
Recommended Method
Add your table to apiHookTables in the extension configuration. This automatically triggers geolocation when saving a record.
Manual Hook (Alternative)
If you prefer a custom hook, register it in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['myhook'] = \Vendor\Extension\Hooks\TceMainHooks::class;
In your hook class, call the Geolocation service:
use Gadgeto\GadgetoGoogle\Service\GeolocationService;
See the example in Classes/Hooks/TceMainHooks.php.
👥 GDPR Consent Overlay
To comply with GDPR (DSGVO), a consent dialog must be shown before loading Google Maps. This overlay is part of the extension.
There is a config-file for klaro-consent-manager included. You can use it with ext:klarokartie by adding the following lines to your site-config (yaml):
klarokratie:
klaro:
config: EXT:klarokratie/Resources/Public/Config/KlaroConfigMinimal.js
includes:
- EXT:gadgeto_google/Resources/Public/Klarokratie/Includes/GoogleMaps.js
If you want to use a different consent manager, you can use the following JavaScript-Events depending on a given or revoked consent:
document.dispatchEvent(new CustomEvent('gadgetoGoogle:consent:given'));
document.dispatchEvent(new CustomEvent('gadgetoGoogle:consent:revoked'));
📚 Resources
madj2k/t3-gadgeto-google 适用场景与选型建议
madj2k/t3-gadgeto-google 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 662 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geolocation」 「google maps」 「TYPO3 CMS」 「Google Geo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 madj2k/t3-gadgeto-google 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 madj2k/t3-gadgeto-google 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 madj2k/t3-gadgeto-google 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
A Laravel Nova Google Maps Field.
The official PHP library for apiip.net that allowing customers to automate IP address validation and geolocation lookup in websites, applications and back-office system. Visit our API docs at https://apiip.net/documentation
Google Maps PHP SDK.
Supports GeoIP services (sypexgeo.net).
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
统计信息
- 总下载量: 662
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2024-05-05