WIP for polyline.
This commit is contained in:
parent
495bbbb095
commit
aaa90f6d53
@ -52,7 +52,7 @@ class staticMapLite
|
|||||||
protected $useTileCache = true;
|
protected $useTileCache = true;
|
||||||
protected $tileCacheBaseDir = '../cache/tiles';
|
protected $tileCacheBaseDir = '../cache/tiles';
|
||||||
|
|
||||||
protected $useMapCache = true;
|
protected $useMapCache = false;
|
||||||
protected $mapCacheBaseDir = '../cache/maps';
|
protected $mapCacheBaseDir = '../cache/maps';
|
||||||
protected $mapCacheID = '';
|
protected $mapCacheID = '';
|
||||||
protected $mapCacheFile = '';
|
protected $mapCacheFile = '';
|
||||||
@ -115,12 +115,8 @@ class staticMapLite
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (!empty($_GET['polylines'])) {
|
if (!empty($_GET['polylines'])) {
|
||||||
$polylines = explode('|', $_GET['polylines']);
|
list($polylineString, $colorRed, $colorGreen, $colorBlue) = explode(',', $_GET['polylines']);
|
||||||
foreach ($polylines as $polyline) {
|
$this->polylines[] = array('polyline' => $polylineString, 'colorRed' => $colorRed, 'colorGreen' => $colorGreen, 'colorBlue' => $colorBlue);
|
||||||
list($polylineString, $colorRed, $colorGreen, $colorBlue) = explode(',', $polyline);
|
|
||||||
$this->polylines[] = array('polyline' => $polylineString, 'colorRed' => $colorRed, 'colorGreen' => $colorGreen, 'colorBlue' => $colorBlue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($_GET['maptype']) {
|
if ($_GET['maptype']) {
|
||||||
if (array_key_exists($_GET['maptype'], $this->tileSrcUrl)) $this->maptype = $_GET['maptype'];
|
if (array_key_exists($_GET['maptype'], $this->tileSrcUrl)) $this->maptype = $_GET['maptype'];
|
||||||
@ -265,8 +261,52 @@ class staticMapLite
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pu
|
public function placePolylines()
|
||||||
|
{
|
||||||
|
// loop thru marker array
|
||||||
|
foreach ($this->polylines as $polyline) {
|
||||||
|
// set some local variables
|
||||||
|
$polylineString = $polyline['polyline'];
|
||||||
|
$colorRed = $polyline['Red'];
|
||||||
|
$colorGreen = $polyline['colorGreen'];
|
||||||
|
$colorBlue = $polyline['colorBlue'];
|
||||||
|
|
||||||
|
// clear variables from previous loops
|
||||||
|
|
||||||
|
$polylineList = \Polyline::decode($polylineString);
|
||||||
|
|
||||||
|
$sourceLatitude = null;
|
||||||
|
$sourceLongitude = null;
|
||||||
|
$destinationLatitude = null;
|
||||||
|
$destinationLongitude = null;
|
||||||
|
|
||||||
|
$color = imagecolorallocate($this->image, $colorRed, $colorGreen, $colorBlue);
|
||||||
|
|
||||||
|
while (!empty($polylineList)) {
|
||||||
|
if (!$sourceLatitude) {
|
||||||
|
$sourceLatitude = array_shift($polylineList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sourceLongitude) {
|
||||||
|
$sourceLongitude = array_shift($polylineList);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sourceX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($sourceLongitude, $this->zoom)));
|
||||||
|
$sourceY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($sourceLatitude, $this->zoom)));
|
||||||
|
|
||||||
|
$destinationLatitude = array_shift($polylineList);
|
||||||
|
$destinationLongitude = array_shift($polylineList);
|
||||||
|
|
||||||
|
$destinationX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($destinationLongitude, $this->zoom)));
|
||||||
|
$destinationY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($destinationLatitude, $this->zoom)));
|
||||||
|
|
||||||
|
imageline($this->image , $sourceX, $sourceY , $destinationX, $destinationY, $color);
|
||||||
|
|
||||||
|
$sourceLatitude = $destinationLatitude;
|
||||||
|
$sourceLongitude = $destinationLongitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function tileUrlToFilename($url)
|
public function tileUrlToFilename($url)
|
||||||
{
|
{
|
||||||
@ -352,6 +392,7 @@ class staticMapLite
|
|||||||
$this->initCoords();
|
$this->initCoords();
|
||||||
$this->createBaseMap();
|
$this->createBaseMap();
|
||||||
if (count($this->markers)) $this->placeMarkers();
|
if (count($this->markers)) $this->placeMarkers();
|
||||||
|
if (count($this->polylines)) $this->placePolylines();
|
||||||
if ($this->osmLogo) $this->copyrightNotice();
|
if ($this->osmLogo) $this->copyrightNotice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user