-
Notifications
You must be signed in to change notification settings - Fork 6
Examples
Matt Sparks edited this page Jul 4, 2017
·
5 revisions
For installation instructions, see the Installation page.
At a minimum, Static Maps requires the main StaticMaps
class and the Map
component.
use SparksCoding\StaticMaps\StaticMap;
use SparksCoding\StaticMaps\Components\Map;
// Add your api key
$staticMap = StaticMap::key('your_api_key');
// Set the builder
$staticMap->setBuilder('\SparksCoding\StaticMaps\Builders\GoogleStaticMapBuilder');
// Add the map
$staticMap->setMap(
Map::create()->center('New York, NY')->zoom(10)
);
// Get the URI
$staticMap->uri();
$staticMap->addMarkers(
Marker::location('Midtown Manhattan, New York, NY'),
Marker::location('Brooklyn, NY'),
Marker::location('Empire State Building'),
);
$staticMap->addStyles(
Feature::name('road')->elements(
Element::name('geometry')->color('blue')
),
Feature::name('landscape')->elements(
Element::name('labels')->color('red')
)
);
$staticMap->addPath(
Path::points([
'Empire State Building',
'Webster Hall',
'The Spotted Pig',
'The High Line',
'Empire State Building',
])->color('0x000000ff')->fillcolor('0xFFFF0033')->weight(2)
);