WIP.
This commit is contained in:
parent
233b291df8
commit
653b6c1877
53
src/ElementPrinter/Marker/ExtraMarkerPrinter.php
Normal file
53
src/ElementPrinter/Marker/ExtraMarkerPrinter.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace StaticMapLite\ElementPrinter\Marker;
|
||||
|
||||
use StaticMapLite\Canvas\Canvas;
|
||||
use StaticMapLite\Element\Marker\AbstractMarker;
|
||||
use StaticMapLite\Element\Marker\ExtraMarker;
|
||||
use StaticMapLite\Element\Marker\Marker;
|
||||
use StaticMapLite\Util;
|
||||
|
||||
class ExtraMarkerPrinter
|
||||
{
|
||||
/** @var Marker $marker */
|
||||
protected $marker = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function setMarker(AbstractMarker $marker): ExtraMarkerPrinter
|
||||
{
|
||||
$this->marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function paint(Canvas $canvas): ExtraMarkerPrinter
|
||||
{
|
||||
$extramarkersImgUrl = __DIR__.'/../../../images/extramarkers.png';
|
||||
$extramarkers = imagecreatefrompng($extramarkersImgUrl);
|
||||
|
||||
$markerImage = imagecreatetruecolor(75, 100);
|
||||
$trans_colour = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
|
||||
imagefill($markerImage, 0, 0, $trans_colour);
|
||||
|
||||
$destX = floor(($canvas->getWidth() / 2) - $canvas->getTileSize() * ($canvas->getCenterX() - Util::lonToTile($this->marker->getLongitude(), $canvas->getZoom())));
|
||||
$destY = floor(($canvas->getHeight() / 2) - $canvas->getTileSize() * ($canvas->getCenterY() - Util::latToTile($this->marker->getLatitude(), $canvas->getZoom())));
|
||||
|
||||
$markerWidth = imagesx($markerImage);
|
||||
$markerHeight = imagesy($markerImage);
|
||||
|
||||
$destX -= $markerWidth / 2;
|
||||
$destY -= $markerHeight;
|
||||
|
||||
|
||||
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
|
||||
|
||||
imagecopy($canvas->getImage(), $markerImage, $destX, $destY, 0, 0, imagesx($markerImage), imagesy($markerImage));
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace StaticMapLite\ElementPrinter\Marker;
|
||||
|
||||
use StaticMapLite\Canvas\Canvas;
|
||||
use StaticMapLite\Element\Marker\AbstractMarker;
|
||||
use StaticMapLite\Element\Marker\ExtraMarker;
|
||||
use StaticMapLite\Element\Marker\Marker;
|
||||
use StaticMapLite\Util;
|
||||
@ -50,37 +51,13 @@ class MarkerPrinter
|
||||
|
||||
}
|
||||
|
||||
public function setMarker(Marker $marker): MarkerPrinter
|
||||
public function setMarker(AbstractMarker $marker): MarkerPrinter
|
||||
{
|
||||
$this->marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
public function placeExtraMarker(ExtraMarker $extraMarker)
|
||||
{
|
||||
$extramarkers = imagecreatefrompng($this->markerBaseDir . '/../extramarkers.png');
|
||||
|
||||
$markerImage = imagecreatetruecolor(75, 100);
|
||||
$trans_colour = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
|
||||
imagefill($markerImage, 0, 0, $trans_colour);
|
||||
|
||||
$destX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - Util::lonToTile($extraMarker->getLongitude(), $this->zoom)));
|
||||
$destY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - Util::latToTile($extraMarker->getLatitude(), $this->zoom)));
|
||||
|
||||
$markerWidth = imagesx($markerImage);
|
||||
$markerHeight = imagesy($markerImage);
|
||||
|
||||
$destX -= $markerWidth / 2;
|
||||
$destY -= $markerHeight;
|
||||
|
||||
|
||||
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
|
||||
|
||||
imagecopy($this->canvas->getImage(), $markerImage, $destX, $destY, 0, 0, imagesx($markerImage), imagesy($markerImage));
|
||||
}
|
||||
**/
|
||||
public function paint(Canvas $canvas): MarkerPrinter
|
||||
{
|
||||
$markerFilename = '';
|
||||
|
@ -6,6 +6,7 @@ use StaticMapLite\Canvas\Canvas;
|
||||
use StaticMapLite\CanvasTilePainter\CanvasTilePainter;
|
||||
use StaticMapLite\Element\Marker\AbstractMarker;
|
||||
use StaticMapLite\Element\Polyline\Polyline;
|
||||
use StaticMapLite\ElementPrinter\Marker\ExtraMarkerPrinter;
|
||||
use StaticMapLite\ElementPrinter\Marker\MarkerPrinter;
|
||||
use StaticMapLite\ElementPrinter\Polyline\PolylinePrinter;
|
||||
use StaticMapLite\TileResolver\CachedTileResolver;
|
||||
@ -148,7 +149,7 @@ class Printer
|
||||
|
||||
public function placeMarkers()
|
||||
{
|
||||
$printer = new MarkerPrinter();
|
||||
$printer = new ExtraMarkerPrinter();
|
||||
|
||||
foreach ($this->markers as $marker) {
|
||||
$printer
|
||||
|
@ -28,7 +28,6 @@
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
use StaticMapLite\Element\Marker\ExtraMarker;
|
||||
use StaticMapLite\Element\Marker\Marker;
|
||||
use StaticMapLite\Element\Polyline\Polyline;
|
||||
use StaticMapLite\Printer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user