From 240b348e67d0e4b0a796bd12fcf505ba37455869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Hu=CC=88bner?= Date: Thu, 8 Jun 2017 20:39:01 +0200 Subject: [PATCH] WIP. --- src/ElementPrinter/Marker/MarkerPrinter.php | 8 ++++++-- src/Printer.php | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ElementPrinter/Marker/MarkerPrinter.php b/src/ElementPrinter/Marker/MarkerPrinter.php index ad8e083..9d11c78 100644 --- a/src/ElementPrinter/Marker/MarkerPrinter.php +++ b/src/ElementPrinter/Marker/MarkerPrinter.php @@ -102,8 +102,8 @@ class MarkerPrinter } // calc position - $destX = floor(($canvas->getWidth() / 2) - $this->tileSize * ($canvas->getCenterY() - Util::lonToTile($this->marker->getLongitude(), $this->zoom))); - $destY = floor(($canvas->getHeight() / 2) - $this->tileSize * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $this->zoom))); + $destX = floor(($canvas->getWidth() / 2) - $this->tileSize * ($canvas->getCenterX() - Util::lonToTile($this->marker->getLongitude(), $canvas->getZoom()))); + $destY = floor(($canvas->getHeight() / 2) - $this->tileSize * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $canvas->getZoom()))); // copy shadow on basemap if ($markerShadow && $markerShadowImg) { @@ -114,5 +114,9 @@ class MarkerPrinter // copy marker on basemap above shadow imagecopy($canvas->getImage(), $markerImg, $destX + intval($markerImageOffsetX), $destY + intval($markerImageOffsetY), 0, 0, imagesx($markerImg), imagesy($markerImg)); + + + return $this; } + } \ No newline at end of file diff --git a/src/Printer.php b/src/Printer.php index 97fb7ea..cddab90 100644 --- a/src/Printer.php +++ b/src/Printer.php @@ -5,6 +5,7 @@ namespace StaticMapLite; use StaticMapLite\Canvas\Canvas; use StaticMapLite\Element\Marker\Marker; use StaticMapLite\Element\Polyline\Polyline; +use StaticMapLite\ElementPrinter\Marker\MarkerPrinter; use StaticMapLite\ElementPrinter\Polyline\PolylinePrinter; use StaticMapLite\TileResolver\CachedTileResolver; @@ -168,10 +169,14 @@ class Printer public function placeMarkers() { + $printer = new MarkerPrinter(); + foreach ($this->markers as $marker) { - - - }; + $printer + ->setMarker($marker) + ->paint($this->canvas) + ; + } } public function placePolylines()