This commit is contained in:
Malte Hübner 2017-06-08 20:39:01 +02:00
parent bd9e686cf0
commit 240b348e67
2 changed files with 14 additions and 5 deletions

View File

@ -102,8 +102,8 @@ class MarkerPrinter
} }
// calc position // calc position
$destX = floor(($canvas->getWidth() / 2) - $this->tileSize * ($canvas->getCenterY() - Util::lonToTile($this->marker->getLongitude(), $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(), $this->zoom))); $destY = floor(($canvas->getHeight() / 2) - $this->tileSize * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $canvas->getZoom())));
// copy shadow on basemap // copy shadow on basemap
if ($markerShadow && $markerShadowImg) { if ($markerShadow && $markerShadowImg) {
@ -114,5 +114,9 @@ class MarkerPrinter
// copy marker on basemap above shadow // copy marker on basemap above shadow
imagecopy($canvas->getImage(), $markerImg, $destX + intval($markerImageOffsetX), $destY + intval($markerImageOffsetY), imagecopy($canvas->getImage(), $markerImg, $destX + intval($markerImageOffsetX), $destY + intval($markerImageOffsetY),
0, 0, imagesx($markerImg), imagesy($markerImg)); 0, 0, imagesx($markerImg), imagesy($markerImg));
return $this;
} }
} }

View File

@ -5,6 +5,7 @@ namespace StaticMapLite;
use StaticMapLite\Canvas\Canvas; use StaticMapLite\Canvas\Canvas;
use StaticMapLite\Element\Marker\Marker; use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Polyline\Polyline; use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\ElementPrinter\Marker\MarkerPrinter;
use StaticMapLite\ElementPrinter\Polyline\PolylinePrinter; use StaticMapLite\ElementPrinter\Polyline\PolylinePrinter;
use StaticMapLite\TileResolver\CachedTileResolver; use StaticMapLite\TileResolver\CachedTileResolver;
@ -168,10 +169,14 @@ class Printer
public function placeMarkers() public function placeMarkers()
{ {
$printer = new MarkerPrinter();
foreach ($this->markers as $marker) { foreach ($this->markers as $marker) {
$printer
->setMarker($marker)
}; ->paint($this->canvas)
;
}
} }
public function placePolylines() public function placePolylines()