Commit all the old stuff.
This commit is contained in:
parent
aae0ada3c6
commit
62bfbea776
BIN
images/extramarkers.png
Normal file
BIN
images/extramarkers.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 248 KiB |
26
src/Element/Marker/AbstractMarker.php
Normal file
26
src/Element/Marker/AbstractMarker.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: maltehuebner
|
||||
* Date: 29.09.17
|
||||
* Time: 15:46
|
||||
*/
|
||||
|
||||
namespace StaticMapLite\Element\Marker;
|
||||
|
||||
|
||||
class AbstractMarker
|
||||
{
|
||||
protected $latitude;
|
||||
protected $longitude;
|
||||
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
}
|
38
src/Element/Marker/ExtraMarker.php
Normal file
38
src/Element/Marker/ExtraMarker.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace StaticMapLite\Element\Marker;
|
||||
|
||||
class ExtraMarker extends AbstractMarker
|
||||
{
|
||||
const SHAPE_CIRCLE = 0;
|
||||
const SHAPE_SQUARE = 1;
|
||||
const SHAPE_STAR = 2;
|
||||
const SHAPE_PENTA = 3;
|
||||
|
||||
const COLOR_RED = 0;
|
||||
const COLOR_ORANGEDARK = 1;
|
||||
const COLOR_ORANGE = 2;
|
||||
const COLOR_YELLOW = 3;
|
||||
const COLOR_BLUEDARK = 4;
|
||||
const COLOR_CYAN = 5;
|
||||
const COLOR_PURPLE = 6;
|
||||
const COLOR_VIOLET = 7;
|
||||
const COLOR_PINK = 8;
|
||||
const COLOR_GREENDARK = 9;
|
||||
const COLOR_GREEN = 10;
|
||||
const COLOR_GREENLIGHT = 11;
|
||||
const COLOR_BLACK = 12;
|
||||
const COLOR_WHITE = 13;
|
||||
|
||||
protected $shape;
|
||||
protected $color;
|
||||
|
||||
public function __construct(int $shape, int $color, float $latitude, float $longitude)
|
||||
{
|
||||
$this->shape = $shape;
|
||||
$this->color = $color;
|
||||
|
||||
$this->latitude = $latitude;
|
||||
$this->longitude = $longitude;
|
||||
}
|
||||
}
|
@ -2,10 +2,8 @@
|
||||
|
||||
namespace StaticMapLite\Element\Marker;
|
||||
|
||||
class Marker
|
||||
class Marker extends AbstractMarker
|
||||
{
|
||||
protected $latitude;
|
||||
protected $longitude;
|
||||
protected $markerType;
|
||||
|
||||
public function __construct(string $markerType, float $latitude, float $longitude)
|
||||
@ -20,13 +18,5 @@ class Marker
|
||||
return $this->markerType;
|
||||
}
|
||||
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace StaticMapLite;
|
||||
|
||||
use StaticMapLite\Canvas\Canvas;
|
||||
use StaticMapLite\Element\Marker\AbstractMarker;
|
||||
use StaticMapLite\Element\Marker\ExtraMarker;
|
||||
use StaticMapLite\Element\Marker\Marker;
|
||||
use StaticMapLite\Element\Polyline\Polyline;
|
||||
use StaticMapLite\TileResolver\CachedTileResolver;
|
||||
@ -89,7 +91,7 @@ class Printer
|
||||
$this->tileResolver->setTileLayerUrl($this->tileSrcUrl[$this->maptype]);
|
||||
}
|
||||
|
||||
public function addMarker(Marker $marker): Printer
|
||||
public function addMarker(AbstractMarker $marker): Printer
|
||||
{
|
||||
$this->markers[] = $marker;
|
||||
|
||||
@ -189,10 +191,38 @@ class Printer
|
||||
}
|
||||
}
|
||||
|
||||
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 placeMarkers()
|
||||
{
|
||||
foreach ($this->markers as $marker) {
|
||||
if ($marker instanceof ExtraMarker) {
|
||||
$this->placeExtraMarker($marker);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$markerFilename = '';
|
||||
$markerShadow = '';
|
||||
$matches = false;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
use StaticMapLite\Element\Marker\ExtraMarker;
|
||||
use StaticMapLite\Element\Marker\Marker;
|
||||
use StaticMapLite\Printer;
|
||||
|
||||
@ -50,7 +51,7 @@ if ($markers) {
|
||||
foreach ($markerList as $marker) {
|
||||
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $marker);
|
||||
|
||||
$marker = new Marker($markerType, $markerLatitude, $markerLongitude);
|
||||
$marker = new ExtraMarker(ExtraMarker::SHAPE_CIRCLE, ExtraMarker::COLOR_GREEN, $markerLatitude, $markerLongitude);
|
||||
|
||||
$printer->addMarker($marker);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user