sparkscoding / static-maps
一个PHP库,使使用Google静态地图API变得更加友好。
v1.1.0-beta
2017-07-07 01:47 UTC
This package is auto-updated.
Last update: 2024-09-24 05:51:08 UTC
README
一个PHP库,使使用Google静态地图API(以及最终其他API)变得更加友好。
注意:这个库正在积极开发中。需要重构,需要添加功能,API需要最终确定。尽管代码应该相对稳定,但建议不要在生产环境中使用。
安装
Composer是推荐的安装方法。
composer require sparkscoding/static-maps
快速示例
use SparksCoding\StaticMaps\StaticMap; use SparksCoding\StaticMaps\Components\Map; use SparksCoding\StaticMaps\Components\Marker; use SparksCoding\StaticMaps\Components\Feature; use SparksCoding\StaticMaps\Components\Element; use SparksCoding\StaticMaps\Components\Path; // Initialize the map by adding your API key $staticMap = StaticMap::key('123yOUrAPIkeYGoeSHerE123'); // Set the builder $staticMap->setBuilder( '\SparksCoding\StaticMaps\Builders\GoogleStaticMapBuilder' ); // Add a map $staticMap->setMap( Map::create()->center('New York, NY')->zoom(10) ); // Add a couple markers $staticMap->addMarkers( Marker::location('New York, NY'), Marker::location('Brooklyn, NY') ); // Style the roads $staticMap->addStyles( Feature::name('road')->elements( Element::name('geometry')->color('blue') ) ); // Add a path $staticMap->addPath( Path::points([ 'Empire State Building', 'Webster Hall', 'The Spotted Pig', 'The High Line', 'Empire State Building', ])->color('0x000000ff')->fillcolor('0xFFFF0033')->weight(2) ); echo '<img src="' . $staticMap->uri() . '">';
输出
文档
文档,包括安装说明和示例,可以在Wiki上找到。
