Merge pull request #1 from mores/StaticMap_dropIn

Can now act as dropIn replacement for StaticMap by ojw
This commit is contained in:
dFacts Network 2014-12-15 23:15:55 +01:00
commit 8dab3826c3
2 changed files with 36 additions and 2 deletions

BIN
images/markers/bullseye.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -65,8 +65,14 @@ Class staticMapLite
'shadow' => '../marker_shadow.png', 'shadow' => '../marker_shadow.png',
'offsetImage' => '-10,-32', 'offsetImage' => '-10,-32',
'offsetShadow' => '-1,-13' 'offsetShadow' => '-1,-13'
),
// http://svn.openstreetmap.org/sites/other/StaticMap/symbols/0.png
'ojw' => array('regex' => '/^bullseye$/',
'extension' => '.png',
'shadow' => false,
'offsetImage' => '-20,-20',
'offsetShadow' => false
) )
); );
@ -97,6 +103,16 @@ Class staticMapLite
{ {
global $_GET; global $_GET;
if (!empty($_GET['show'])) {
$this->parseOjwParams();
}
else {
$this->parseLiteParams();
}
}
public function parseLiteParams()
{
// get zoom from GET paramter // get zoom from GET paramter
$this->zoom = $_GET['zoom'] ? intval($_GET['zoom']) : 0; $this->zoom = $_GET['zoom'] ? intval($_GET['zoom']) : 0;
if ($this->zoom > 18) $this->zoom = 18; if ($this->zoom > 18) $this->zoom = 18;
@ -130,6 +146,24 @@ Class staticMapLite
} }
} }
public function parseOjwParams()
{
$this->lat = floatval($_GET['lat']);
$this->lon = floatval($_GET['lon']);
$this->zoom = intval($_GET['z']);
$this->width = intval($_GET['w']);
$this->height = intval($_GET['h']);
if (!empty($_GET['mlat0'])) {
$markerLat = floatval($_GET['mlat0']);
if (!empty($_GET['mlon0'])) {
$markerLon = floatval($_GET['mlon0']);
$this->markers[] = array('lat' => $markerLat, 'lon' => $markerLon, 'type' => "bullseye");
}
}
}
public function lonToTile($long, $zoom) public function lonToTile($long, $zoom)
{ {
return (($long + 180) / 360) * pow(2, $zoom); return (($long + 180) / 360) * pow(2, $zoom);
@ -369,4 +403,4 @@ Class staticMapLite
} }
$map = new staticMapLite(); $map = new staticMapLite();
print $map->showMap(); print $map->showMap();