nicat / static-map
使用 Static Map Maker 生成 Yandex、Google、MapBox、Bing、CartoDB、HERE、MapQuest 静态地图
v1.0.2
2017-02-16 21:25 UTC
Requires
- php: ~5.5|~7.0
- illuminate/support: ~5.1
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-09-20 18:08:56 UTC
README
安装
首先,通过 Composer 拉取此包。
运行 composer require nicat/static-map
然后,如果使用 Laravel 5,在 config/app.php
中包含服务提供者。
'providers' => [ Nicat\StaticMap\StaticMapServiceProvider::class, ];
为了方便,可以在该文件的底部添加一个外观别名
'aliases' => [ 'StaticMap' => Nicat\StaticMap\Facade\StaticMap::class, ];
如果您需要修改静态地图片段,可以运行
php artisan vendor:publish
用法
在您的控制器中
StaticMap::Google('London')
您也可以这样做
StaticMap::Google('伦敦')
StaticMap::Google('37.6213129,-122.3811441')
StaticMap::GoogleWithImg('伦敦')
StaticMap::Google('伦敦', ['with' => 600, 'height' => 500, 'mapType' => 'hybrid'])
您可以修改片段
'width' => 600, // Width of Map image 'height' => 400, // Height of Map Image 'mapType' => 'roadmap', // Map type ['roadmap', 'terrain', 'satellite', 'hyrid'] 'imageFormat' => 'png', // gif, png or jpg 'zoom' => 14, // Zoom of Map
您还可以添加标记
{!! StaticMap::GoogleWithImg('London', ['markers' => ['center' => 'Westminster London', 'label' => '2'], 'imageType' => 'gif'])
如果您只想添加主要中心的标记
{!! StaticMap::GoogleWithImg('37.6213129,-122.3811441', ['markers' => true]) !!}
如果您只想使用带有地图链接的标记
{!! StaticMap::GoogleWithLink('37.6213129,-122.3811441', ['markers' => true]) !!}
标记选项
'center' => '37.6213129,-122.3811441', // or 'San Francisco International Airport' 'label' => '1', // Label Name of Marker 'color' => '0xff0000', // color of marker 'size' => 'mid', // tiny (Small),small (Medium), mid (Large)
##一些示例
{!! StaticMap::GoogleWithImg('San Francisco International Airport', ['markers' => [ ['center' => 'San Bruno', 'label' => '2'], ['center' => '37.6213129,-122.3711441', 'label' => '1'] ] ]) !!}
{!! StaticMap::GoogleWithImg('37.6213129,-122.3811441', ['with' => 600, 'height' => 500, 'mapType' => 'hybrid']) !!}