genealabs/laravel-maps 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

genealabs/laravel-maps

最新稳定版本:0.9.0

Composer 安装命令:

composer require genealabs/laravel-maps

包简介

Easy-peasy map integration for Laravel.

README 文档

README

GitHub (pre-)release Packagist GitHub license

Version Support

Laravel PHP
11.x 8.2, 8.3, 8.4, 8.5
12.x 8.2, 8.3, 8.4, 8.5
13.x 8.3, 8.4, 8.5

Prerequisites

  • PHP >= 8.2
  • Laravel >= 11.0

This package is the continuation of GeneaLabs/Phpgmaps. The move to the more appropriately-named package namespace is in preparation for a complete rewrite of the package, optimizing it for Laravel.

PhpGmaps

This repo aims to keep appitventures/phpgmaps alive, hopefully filling in temporarily until they make their repo available again, or else continuing its maintenance going forward and keeping it working with future versions of Laravel.

Installation

Add the repo to composer.json under this new namespace:

composer require genealabs/laravel-maps

Add an environment variable with your Google Maps API Key in your .env file:

GOOGLE_MAPS_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Lastly, add the following entry to your \config\services.php config file:

    'google' => [
        'maps' => [
            'api-key' => env('GOOGLE_MAPS_API_KEY'),
        ],
    ],

Example

The following code will prompt the user for access to their geolocation and then creates a map centered on their lat/lng

Route::get('/', function(){
    $config = array();
    $config['center'] = 'auto';
    $config['onboundschanged'] = 'if (!centreGot) {
            var mapCentre = map.getCenter();
            marker_0.setOptions({
                position: new google.maps.LatLng(mapCentre.lat(), mapCentre.lng())
            });
        }
        centreGot = true;';

    app('map')->initialize($config);

    // set up the marker ready for positioning
    // once we know the users location
    $marker = array();
    app('map')->add_marker($marker);

    $map = app('map')->create_map();
    echo "<html><head><script type="text/javascript">var centreGot = false;</script>".$map['js']."</head><body>".$map['html']."</body></html>";
});

More Examples

BIOINSTALL has a great website showing how to do all the things with the class. No reason to reinvent the wheel, so here it is. The only thing to note is that $this->googlemaps is now either the facade Map:: or the app variable app('map').

统计信息

  • 总下载量: 30.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 83
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 82
  • Watchers: 5
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固