WIP for polylines.

This commit is contained in:
Malte Hübner 2017-06-08 20:09:43 +02:00
parent aae0ada3c6
commit 45ee43895f
3 changed files with 21 additions and 5 deletions

View File

@ -9,7 +9,7 @@ class Polyline
protected $colorGreen = 0;
protected $colorBlue = 0;
public function __construct(string $polyline, int $colorRed, int $colorGreen, int $colorBlue)
public function __construct(string $polyline, int $colorRed = 0, int $colorGreen = 0, int $colorBlue = 0)
{
$this->polyline = $polyline;

View File

@ -63,7 +63,6 @@ class Printer
protected $useTileCache = true;
protected $useMapCache = false;
protected $mapCacheBaseDir = '../cache/maps';
protected $mapCacheID = '';
@ -262,7 +261,7 @@ class Printer
$destinationLongitude = null;
$color = imagecolorallocate($this->canvas->getImage(), $polyline->getColorRed(), $polyline->getColorGreen(), $polyline->getColorBlue());
imagesetthickness($this->image, 3);
imagesetthickness($this->image, 5);
//imageantialias($this->image, true);
while (!empty($polylineList)) {

View File

@ -28,6 +28,7 @@
require_once '../vendor/autoload.php';
use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\Printer;
$printer = new Printer();
@ -47,8 +48,8 @@ $markers = $_GET['markers'];
if ($markers) {
$markerList = explode('|', $markers);
foreach ($markerList as $marker) {
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $marker);
foreach ($markerList as $markerData) {
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $markerData);
$marker = new Marker($markerType, $markerLatitude, $markerLongitude);
@ -56,4 +57,20 @@ if ($markers) {
}
}
$polylines = $_GET['polylines'];
if ($polylines) {
$polylineList = explode('|', $polylines);
foreach ($polylineList as $polylineData) {
list($polyline64String, $colorRed, $colorGreen, $colorBlue) = explode(',', $polylineData);
$polylineString = base64_decode($polyline64String);
$polyline = new Polyline($polylineString, $colorRed, $colorGreen, $colorBlue);
$printer->addPolyline($polyline);
}
}
print $printer->showMap();