From b8b9596c84b5fb1d903497fcc6ab4563b098fe9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Hu=CC=88bner?= Date: Sat, 30 Sep 2017 22:33:23 +0200 Subject: [PATCH] Add color and shape support. --- web/staticmap.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/web/staticmap.php b/web/staticmap.php index 01fe81e..6201d19 100644 --- a/web/staticmap.php +++ b/web/staticmap.php @@ -49,9 +49,9 @@ if ($markers) { $markerList = explode('|', $markers); foreach ($markerList as $markerData) { - list($markerLatitude, $markerLongitude, $markerType) = explode(',', $markerData); + list($markerLatitude, $markerLongitude, $markerShape, $markerColor, $markerIcon) = explode(',', $markerData); - $marker = new ExtraMarker(ExtraMarker::SHAPE_CIRCLE, ExtraMarker::COLOR_BLACK, $markerLatitude, $markerLongitude); + $marker = new ExtraMarker(getMarkerShape($markerShape), getMarkerColor($markerColor), $markerLatitude, $markerLongitude); $printer->addMarker($marker); } @@ -74,3 +74,29 @@ if ($polylines) { } print $printer->showMap(); + +function getMarkerShape(string $markerShape): int +{ + $shapes = ['circle', 'square', 'star', 'penta']; + + $key = array_search($markerShape, $shapes); + + if (false === $key) { + die('This shape is not available'); + } + + return $key; +} + +function getMarkerColor(string $markerColor): int +{ + $colors = ['red', 'orangedark', 'orange', 'yellow', 'bluedark', 'blue', 'cyan', 'purple', 'violet', 'pink', 'greendark', 'green', 'greenlight', 'black', 'white']; + + $key = array_search($markerColor, $colors); + + if (false === $key) { + die('This color is not available'); + } + + return $key; +} \ No newline at end of file