ghanem/google-map
Composer 安装命令:
composer require ghanem/google-map
包简介
Google Map with Places Autocomplete field for Laravel Nova 4 & 5.
README 文档
README
Nova Google Map with Autocomplete
A Laravel Nova field that provides an interactive Google Map with Places Autocomplete for picking locations. Users can search for addresses, drag a marker, or enter coordinates manually.
Requirements
- PHP 8.1+
- Laravel Nova 4.x or 5.x
- A Google Cloud API key with Maps JavaScript API and Places API enabled
Installation
composer require ghanem/google-map
Publish the config file:
php artisan vendor:publish --provider="Ghanem\GoogleMap\FieldServiceProvider"
Configuration
Add your Google Maps API key to .env:
GMAPS_API_KEY=your-api-key-here
Optional environment variables with their defaults:
GMAPS_DEFAULT_LATITUDE=41.657523 GMAPS_DEFAULT_LONGITUDE=-101.157292 GMAPS_DEFAULT_ZOOM=3
Get your API key from the Google Cloud Console. Make sure to enable both Maps JavaScript API and Places API.
Usage
Add the field to your Nova resource:
use Ghanem\GoogleMap\GHMap; public function fields(NovaRequest $request): array { return [ // ... GHMap::make('Location'), ]; }
Your model needs latitude and longitude columns (or custom names — see below).
Custom Field Names
If your database columns are not named latitude and longitude:
GHMap::make('Location') ->latitude('lat') ->longitude('lng'),
Hide Coordinate Inputs
GHMap::make('Location') ->hideLatitude() ->hideLongitude(),
Custom Zoom Level
GHMap::make('Location') ->zoom(10),
Override API Key Per Field
GHMap::make('Location') ->apiKey('different-api-key'),
All Options Combined
GHMap::make('Location') ->latitude('lat') ->longitude('lng') ->zoom(12) ->hideLatitude() ->hideLongitude(),
You can also use any standard Nova field methods (validation, visibility, etc.):
GHMap::make('Location') ->rules('required') ->hideFromIndex(),
Events
When a location is selected (via autocomplete or marker drag), the field emits Nova events that you can listen to in other custom fields:
| Event | Description |
|---|---|
address-update |
Full formatted address |
city-update |
City / locality name |
state-update |
State / administrative area |
country-update |
Country name |
zip-code-update |
Postal code |
latitude-update |
Latitude value (incoming) |
longitude-update |
Longitude value (incoming) |
Changelog
See CHANGELOG.md for release history.
License
MIT - see LICENSE for details.
Sponsor
ghanem/google-map 适用场景与选型建议
ghanem/google-map 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 106.42k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2022 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geocoding」 「autocomplete」 「google map」 「nova」 「laravel」 「google places」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ghanem/google-map 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ghanem/google-map 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ghanem/google-map 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
Maps in minutes. Powered by the Google Maps API.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
GISCO Geocoding Provider for Geocoder PHP.
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Dadata API client (https://dadata.ru)
统计信息
- 总下载量: 106.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-06
