Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattsparks/staticmaps
A PHP library to make working with the Google Static Maps API (and, eventually, others) a little more friendly.
https://github.com/mattsparks/staticmaps
google-maps google-static-maps-api library php static-maps static-maps-api
Last synced: 6 days ago
JSON representation
A PHP library to make working with the Google Static Maps API (and, eventually, others) a little more friendly.
- Host: GitHub
- URL: https://github.com/mattsparks/staticmaps
- Owner: mattsparks
- License: mit
- Created: 2017-07-03T15:44:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-07T01:52:08.000Z (over 7 years ago)
- Last Synced: 2024-10-27T01:41:04.354Z (17 days ago)
- Topics: google-maps, google-static-maps-api, library, php, static-maps, static-maps-api
- Language: PHP
- Homepage:
- Size: 292 KB
- Stars: 8
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Static Maps
A PHP library to make working with the Google Static Maps API (and, eventually, others) a little more friendly.**Note:** This library is in active development. Refactoring needs to be done, features need added, and the API needs finalized. While the code *should* be relatively stable, you're cautioned against using this in a production environment.
## Installation
Composer is the recommended method of installation.
```
composer require sparkscoding/static-maps
```## Quick Example
```php
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 '';
```
Output:![NY Static Map](assets/ny_example.png "NY Static Map")
## Documentation
Documentation, including installation instructions and examples, can be found on the [Wiki](https://github.com/mattsparks/StaticMaps/wiki).