Add shapeable maps.

This commit is contained in:
Malte Hübner 2017-09-30 21:16:48 +02:00
parent aec3c45b8d
commit c0bd140466
3 changed files with 20 additions and 7 deletions

View File

@ -35,4 +35,14 @@ class ExtraMarker extends AbstractMarker
$this->latitude = $latitude;
$this->longitude = $longitude;
}
public function getShape(): int
{
return $this->shape;
}
public function getColor(): int
{
return $this->color;
}
}

View File

@ -10,7 +10,7 @@ use StaticMapLite\Util;
class ExtraMarkerPrinter
{
/** @var Marker $marker */
/** @var ExtraMarker $marker */
protected $marker = null;
public function __construct()
@ -48,17 +48,20 @@ class 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);
$markerImage = imagecreatetruecolor(72, 92);
$transparentColor = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
imagefill($markerImage, 0, 0, $transparentColor);
$markerWidth = imagesx($markerImage);
$markerHeight = imagesy($markerImage);
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
$sourceX = $markerWidth * $this->marker->getColor();
$sourceY = $markerHeight * $this->marker->getShape();
imagecopy($markerImage, $extramarkers, 0, 0, $sourceX, $sourceY, $markerWidth, $markerHeight);
$white = imagecolorallocate($markerImage, 255, 255, 255);
imagettftext($markerImage, 24, 0, 16, 42, $white, __DIR__.'/../../../fonts/fontawesome-webfont.ttf', json_decode('""'));
imagettftext($markerImage, 24, 0, 16, 47, $white, __DIR__.'/../../../fonts/fontawesome-webfont.ttf', json_decode('""'));
return $markerImage;
}

View File

@ -51,7 +51,7 @@ if ($markers) {
foreach ($markerList as $markerData) {
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $markerData);
$marker = new ExtraMarker(ExtraMarker::SHAPE_CIRCLE, ExtraMarker::COLOR_GREEN, $markerLatitude, $markerLongitude);
$marker = new ExtraMarker(ExtraMarker::SHAPE_CIRCLE, ExtraMarker::COLOR_BLACK, $markerLatitude, $markerLongitude);
$printer->addMarker($marker);
}