mastani/laravel-google-static-map

Laravel Google 静态地图生成器

2.4 2024-03-22 08:26 UTC

This package is auto-updated.

Last update: 2024-09-22 09:43:59 UTC


README

使用 Google Map API 在 Laravel 中生成静态地图。

Total Downloads Latest Stable Version Latest Unstable Version License

Laravel 5.5 及以上版本安装

$ composer require mastani/laravel-google-static-map

该包将自动注册自身。

Laravel 5.4 版本安装

$ composer require mastani/laravel-google-static-map

接下来,需要注册服务提供者

// config/app.php

'providers' => [
    ...
    Mastani\GoogleStaticMap\GoogleStaticMapServiceProvider::class,
];

非 Laravel 环境下的安装

另一种方式是通过 composer 安装组件。

运行以下命令

$ composer require mastani/laravel-google-static-map

"mastani/laravel-google-static-map": "dev-master"

将以下内容添加到你的 composer.json 文件的 require 部分中。

用法

$map = new \Mastani\GoogleStaticMap\GoogleStaticMap('Place google map API key or leave it empty');
$url = $map->setCenter('Tehran')
           ->setMapType(\Mastani\GoogleStaticMap\MapType::RoadMap)
           ->setZoom(14)
           ->setSize(600, 600)
           ->setFormat(\Mastani\GoogleStaticMap\Format::JPG)
           ->addMarker('Tehran', '1', 'red', \Mastani\GoogleStaticMap\Size::Small)
           ->addMarkerLatLng(35.6907488, 51.3919293, '1', 'red', \Mastani\GoogleStaticMap\Size::Small)
           ->make(); // Return url contain map address.
           // or
           ->download($path); // Download map image

函数

许可证

MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。