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 $colorGreen = 0;
protected $colorBlue = 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; $this->polyline = $polyline;

View File

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

View File

@ -28,6 +28,7 @@
require_once '../vendor/autoload.php'; require_once '../vendor/autoload.php';
use StaticMapLite\Element\Marker\Marker; use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\Printer; use StaticMapLite\Printer;
$printer = new Printer(); $printer = new Printer();
@ -47,8 +48,8 @@ $markers = $_GET['markers'];
if ($markers) { if ($markers) {
$markerList = explode('|', $markers); $markerList = explode('|', $markers);
foreach ($markerList as $marker) { foreach ($markerList as $markerData) {
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $marker); list($markerLatitude, $markerLongitude, $markerType) = explode(',', $markerData);
$marker = new Marker($markerType, $markerLatitude, $markerLongitude); $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(); print $printer->showMap();