Get support for KnpLabs/StaticMapApi

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

KnpLabs/StaticMapApi

GOOGLEâ„¢ STATIC MAP API PHP LIBRARY

This library eases the creation of static maps by generating the URLs for Google's api.

<?php

use Knp\Google\StaticMapApi as Api;

$map = new Api\Map('nantes', '512x512', 8);

?>

<img src="<?php echo $map ?> />

Google Map

Using Points and markers

Point type can handle latitude and longitude. They may be used to center maps or to create paths and markers.

$map = new Api\Map(new Api\Point(47.93845, -3.254653), '512x512', 8);

Markers are created using a MarkerCollection instance. Each instance can manage several markers with the same configuration (color, size, label etc.)

$collection = new Api\MarkerCollection();
$collection->color = 'red';
$collection->label = '1';
$collection->size  = Api\MarkerCollection::SIZE_SMALL;
$collection->shadow = false;
$collection->markers = array('nantes', new Api\Point(47.93845, -3.254653));

$map->markers[] = $collection;

Colors

Of course, Google API understands basic colors names like 'blue', 'yellow' etc. but it is possible to pass 0x0f0f0f form colors. A Color class provides a handy way to manage the hexadecimal translation:

$color = new Api\Color(127, 128, 129);

echo $color; // 0x798081

Paths

Map can display paths based on the order of the given points.

$path = new Api\Path;
$path->color = new Api\Color(0, 56, 200);
$path->weght = 10;
$path->points = array(new Api\Point(47.93845, -3.254653), 'nantes', urlencode('rue de strasbourg'));

$map->paths[] = $path;
Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2