gonoware/laravel-maps
Composer 安装命令:
composer require gonoware/laravel-maps
包简介
Maps for your Laravel application
关键字:
README 文档
README
Using this package you can easily display maps on your website.
Supported map services:
- Google Maps
- OpenStreetMap
- Bing Maps
- MapQuest
- Yandex Maps
- MapKit (beta)
Note: Yandex Maps API does not work in Chrome.
Features
| Google Maps | OpenStreetMap | Bing Maps | MapQuest | Yandex Maps | MapKit | |
|---|---|---|---|---|---|---|
| Map | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| Markers | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| Marker Links | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| Marker Popups | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ |
| Custom Marker Icons | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| Marker Click Event | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Installation
This package can be installed through Composer.
composer require gonoware/laravel-maps
Publish the compiled assets to public/vendor/maps with one of these
commands:
php artisan vendor:publish --tag=maps
php artisan vendor:publish --provider="GoNoWare\Maps\MapsServiceProvider" --tag=public
When updating, use the
--forceswitch to overwrite existing assets:php artisan vendor:publish --tag=maps --force
Optionally, you can also publish the config file of this package with this
command to config/vendor/maps.php:
php artisan vendor:publish --provider="GoNoWare\Maps\MapsServiceProvider" --tag=config
Usage
Load the map styles by adding the following directive to your
Blade template before the </head> closing tag.
@mapstyles
Then add the following directive to your Blade template
before the </body> closing tag, to load the map scripts.
@mapscripts
Basic Map
Display a map by adding the @map directive to your Blade template.
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
])
Map With Markers
You can also show markers / pins / annotations:
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
'markers' => [
[
'title' => 'Go NoWare',
'lat' => 48.134664,
'lng' => 11.555220,
],
],
])
Marker Links
Open a url when a marker is clicked.
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
'markers' => [
[
'title' => 'Go NoWare',
'lat' => 48.134664,
'lng' => 11.555220,
'url' => 'https://gonoware.com',
],
],
])
Marker Popups
Show a popup when a marker is clicked. The popup attribute may contain HTML markup.
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
'markers' => [
[
'title' => 'Go NoWare',
'lat' => 48.134664,
'lng' => 11.555220,
'popup' => '<h3>Details</h3><p>Click <a href="https://gonoware.com">here</a>.</p>',
],
],
])
Custom Marker Icons
Show a custom marker icon. Absolute and relative URLs are supported.
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
'markers' => [
[
'title' => 'Go NoWare',
'lat' => 48.134664,
'lng' => 11.555220,
'url' => 'https://gonoware.com',
'icon' => 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
],
],
])
Additionally you may also specify the icon image size and anchor in pixels. The image will be aligned so that the tip of the icon is at the marker's geographical location.
@map([
'lat' => 48.134664,
'lng' => 11.555220,
'zoom' => 6,
'markers' => [
[
'title' => 'Go NoWare',
'lat' => 48.134664,
'lng' => 11.555220,
'url' => 'https://gonoware.com',
'icon' => 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
'icon_size' => [20, 32],
'icon_anchor' => [0, 32],
],
],
])
Styling
To adjust the height of the map use CSS:
.gnw-map-service {
height: 750px;
}
Change the background of the map container:
.gnw-map-service__osm {
background: rgb(221, 221, 221);
}
Fade in by default when using Bootstrap 3.3.7 or 4+. To replicate or modify the animation use following CSS:
.gnw-map.fade {
transition: opacity .15s linear;
}
.gnw-map.fade:not(.show) {
opacity: 0;
}
Events
Map Initialized
The event LaravelMaps:MapInitialized will be dispatched when a map and its markers were initialized. The DOM element, map,
markers and service name can be accessed via the event details.
window.addEventListener('LaravelMaps:MapInitialized', function (event) {
var element = event.detail.element;
var map = event.detail.map;
var markers = event.detail.markers;
var service = event.detail.service;
console.log('map initialized', element, map, markers, service);
});
Please refer to the respective documentation for advanced customization:
Marker Clicked
The event LaravelMaps:MarkerClicked will be dispatched when a marker was clicked. The DOM element, map, marker and
service name can be accessed via the event details.
window.addEventListener('LaravelMaps:MarkerClicked', function (event) {
var element = event.detail.element;
var map = event.detail.map;
var marker = event.detail.marker;
var service = event.detail.service;
console.log('marker clicked', element, map, marker, service);
});
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email em@gonoware.com instead of using the issue tracker.
Credits
License
Copyright (c) 2018-present Go NoWare
gonoware/laravel-maps 适用场景与选型建议
gonoware/laravel-maps 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28.04k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2018 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「google」 「maps」 「bing」 「osm」 「laravel」 「yandex」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gonoware/laravel-maps 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gonoware/laravel-maps 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gonoware/laravel-maps 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Library for making calls to the Microsoft Translator V2 API
Search engine scrapper
A Laravel Nova Google Maps Field.
Google Maps PHP SDK.
Bing Image Extractor
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
统计信息
- 总下载量: 28.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-29