goldfinch/google-maps
Composer 安装命令:
composer require goldfinch/google-maps
包简介
The module helps to create and manage Google Maps in your Silverstripe project
关键字:
README 文档
README
The module helps to create and manage Google Maps 🌏 in your Silverstripe project. It comes with comprehensive settings that you can use to your advantage. Whether you need to create simple or complex maps 🗺️, markers 📍 and more.
Install
1. Install module
composer require goldfinch/google-maps
2. Create Google Cloud API key with the required libraries
There are two API Libraries that need to be enabled for the proper work of this module.
- Maps JavaScript API for maps integration
- Maps Static API for maps thumbnails and previews
3. Add Google Cloud API key to your .env
APP_GOOGLE_MAPS_KEY=""
4. Implement JavaScript front-end component
via Silverstripe Requirements PHP
Requirements::javascript('goldfinch/google-maps:client/dist/map.js');
via template require
<% require javascript('goldfinch/google-maps:client/dist/map.js') %>
via ES6 module
npm i @googlemaps/js-api-loader
import GoogleMap from '..../vendor/goldfinch/google-maps/client/src/src/map-mod' // import GoogleMap from '@goldfinch/google-maps/src/map-mod'; // with alias document.addEventListener('DOMContentLoaded', () => { new GoogleMap() })
// vite.config.js // * only if you use alias import above import { defineConfig } from 'vite' export default defineConfig(({ command, mode }) => { return { // .. resolve: { alias: [{ find: '@goldfinch', replacement: fileURLToPath(new URL('./vendor/goldfinch', import.meta.url)) }] } // .. } })
Available Taz commands
If you haven't used Taz🌪️ before, taz file must be presented in your root project folder cp vendor/goldfinch/taz/taz taz
Create map segment
php taz make:map-segment
Create InfoWindow template
php taz make:map-infowindow:template
Create MapBlock extension
php taz vendor:google-maps:ext:block
Create Config extension
php taz vendor:google-maps:ext:config
Create MapsAdmin extension
php taz vendor:google-maps:ext:admin
Create MapSegment extension
php taz vendor:google-maps:ext:segment
Create full Yaml config (further config amends are required, you might want to remove what you don't need)
php taz vendor:google-maps:config
Publish all available templates
php taz vendor:google-maps:templates
Runs a bundle of all available
vendor:google-maps:*commands
php taz vendor:google-maps
How to create a new map
Each Google Map is built on what is called Map Segment.
1. Create a map segment
Use Taz🌪️ to generate new Map Segment. It will quickly lead you through the setup and take care of it for you.
php taz make:map-segment
2. Create map record in CMS
Go to /admin/maps and add new map. In the Type we need to select our map segment that has been created the step before (should be selected by default). You can go ahead, add markers and check out the Settings tab if you want.
3. Custom Info Window template (optional)
This module comes with various settings for Maps and Markers. You can also add Info Window for markers and easily customize it for your needs. All you need to do is create your custom InfoWindow template by using Taz
php taz make:map-infowindow:template
Once it's been created, you can go to any marker record you added to your map and select your custom template in Info Window Template dropdown.
Usage
Across templates
Using GoogleMaps global provider.
Render map segment template by type
$GoogleMaps.bySegment(office).RenderSegmentMap
Render map frame only by type
$GoogleMaps.bySegment(office).MapElement
Render map segment template by ID
$GoogleMaps.byID(1).RenderSegmentMap
Render map frame only by ID
$GoogleMaps.byID(1).MapElement
Using elemental block
If you prefer using silverstripe/silverstripe-elemental, you can take a look at Map block that already comes with this module.
Sidenotes
Google Maps iframes might have a blue border that you want to get rid of.
.gm-style iframe + div { border: none !important; }
As of February 21st, 2024, Marker is deprecated. Please use AdvancedMarkerElement instead.
Events
Available JavaScript callback events
window.goldfinch = {} window.goldfinch.map_callback = (map, mapSettings, segment, parameters) => { // .. } window.goldfinch.marker_callback = (marker, markerParams, e, map, segment, parameters) => { // .. } window.goldfinch.infoWindow_callback = (infoWindow, infowindowParams, marker, map, e, segment, parameters) => { // .. }
Previews
Admin
Map segment
Map segment settings
Map's markers
Marker item
Marker settings
License
The MIT License (MIT)
goldfinch/google-maps 适用场景与选型建议
goldfinch/google-maps 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 623 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「google-maps」 「silverstripe」 「silverstripe-google-maps」 「map-events」 「marker-events」 「advancedmarkerelement-events」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 goldfinch/google-maps 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 goldfinch/google-maps 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 goldfinch/google-maps 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.
Laravel package that helps to use GoogleMaps
Analytics chooser extensions for site settings.
Extension google maps for 2amigos google map for yii2
统计信息
- 总下载量: 623
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-18





