wyrihaximus / staticmap
PHP 实现的 Google Maps 静态 API
0.2.2
2013-08-10 21:48 UTC
Requires
- php: >=5.3
- imagine/imagine: 0.4.*
Requires (Dev)
- ext-gd: *
- satooshi/php-coveralls: ~0.6
This package is auto-updated.
Last update: 2024-09-05 06:47:27 UTC
README
PHP 中的静态 Google Maps 复制
入门指南
1. 要求
此插件依赖于以下插件和库,并由 composer 在稍后拉取
ext-gd
2. 安装
通过 Composer 安装,使用以下命令,它将自动检测最新版本并将其与 ~
绑定。
composer require wyrihaximus/staticmap
3. 示例
<?php use Imagine\Gd\Imagine; use Imagine\Image\Box; use WyriHaximus\StaticMap; require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; $width = 256; $height = 256; $zoom = 7; $latitude = 0; $longitude = 0; $renderer = new StaticMap\Renderer( new Imagine(), $zoom, new Box($width, $height), new StaticMap\LatLng($latitude, $longitude), new StaticMap\Tiles('http://example.com/tiles/' . $zoom . '/{x}/{y}.png') ); header('Content-Type: image/png'); echo $renderer->generate()->get('png', array( 'quality' => 9, ));
4. Blips
Blips 是地图上的标记。添加它们很简单
<?php use WyriHaximus\StaticMap\Blip; use WyriHaximus\StaticMap\LatLng; $renderer->addBlip(Blip::create(new LatLng(123, 456), 'http://static.wyrimaps.net/icons/blip.png'));
如果您只想在中心添加一个,这就可以了
<?php $renderer->addCenterBlip();