From 87c59e2dfd5611cd58767f42e73d240927dbe55f Mon Sep 17 00:00:00 2001 From: Harry Wood Date: Sun, 15 Jan 2017 01:21:34 +0000 Subject: [PATCH 1/2] map_type fixes. mapnik->standard, hide osmarender The map_type 'mapnik' value is badly named. Create a new alias 'standard' which is now the new default (which the old 'mapnik' value continues to work as a deprecated value) 'osmarender' has been (badly) mapped to MapQuest open tiles for a while now, so broken because these were discontinued (as was the original 'osmarender' layer) Fix maptype=osmarender so it works, by mapping to osm standard, but obviously this value is also deprecated. Changes to the intro page to reflect this. Fixes https://github.com/dfacts/staticmaplite/issues/3 --- index.html | 16 ++++++---------- staticmap.php | 10 ++++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index c61052b..fccaee8 100644 --- a/index.html +++ b/index.html @@ -70,10 +70,10 @@

staticMapLite - simple map for your website

-

+

This image was created using the following simple <img> tag: -

<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" />
+
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=standard" />


@@ -83,7 +83,7 @@

- +

Add markers by appending them to the image URL:

markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3

@@ -96,12 +96,8 @@

- -
maptype=mapnik
-
-
- -
maptype=osmarenderer
+ +
maptype=standard
@@ -119,4 +115,4 @@

- \ No newline at end of file + diff --git a/staticmap.php b/staticmap.php index a9855e5..047f999 100644 --- a/staticmap.php +++ b/staticmap.php @@ -21,7 +21,7 @@ * * USAGE: * - * staticmap.php?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mapnik&markers=40.702147,-74.015794,blues|40.711614,-74.012318,greeng|40.718217,-73.998284,redc + * staticmap.php?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=standrd&markers=40.702147,-74.015794,blues|40.711614,-74.012318,greeng|40.718217,-73.998284,redc * */ @@ -35,12 +35,14 @@ protected $maxHeight = 1024; protected $tileSize = 256; - protected $tileSrcUrl = array('mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', - 'osmarenderer' => 'http://otile1.mqcdn.com/tiles/1.0.0/osm/{Z}/{X}/{Y}.png', + protected $tileSrcUrl = array( + 'standard' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', + 'mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', /* deprecated alias */ + 'osmarenderer' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', /* mapped value from discontinued tile server */ 'cycle' => 'http://a.tile.opencyclemap.org/cycle/{Z}/{X}/{Y}.png', ); - protected $tileDefaultSrc = 'mapnik'; + protected $tileDefaultSrc = 'standard'; protected $markerBaseDir = 'images/markers'; protected $osmLogo = 'images/osm_logo.png'; From 9530e621418a7337aceab8576b652cef72e291a9 Mon Sep 17 00:00:00 2001 From: Harry Wood Date: Sun, 22 Jan 2017 15:28:46 +0000 Subject: [PATCH 2/2] define mapTypeAliases more explicitly Define 'mapnik' and 'osmrender' explcitly as aliases of 'standard' rather than just setting to the same tile URL. That approach would mean the aliases will have their own cache directory (which is unnecessary). Now they will all use the 'standard' cache directory. --- staticmap.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/staticmap.php b/staticmap.php index 047f999..52e6b29 100644 --- a/staticmap.php +++ b/staticmap.php @@ -37,11 +37,15 @@ protected $tileSize = 256; protected $tileSrcUrl = array( 'standard' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', - 'mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', /* deprecated alias */ - 'osmarenderer' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', /* mapped value from discontinued tile server */ 'cycle' => 'http://a.tile.opencyclemap.org/cycle/{Z}/{X}/{Y}.png', ); + // Deprecated map_type values still supported as aliases + protected $mapTypeAliases = array( + 'mapnik' => 'standard', + 'osmarender' => 'standard' + ); + protected $tileDefaultSrc = 'standard'; protected $markerBaseDir = 'images/markers'; protected $osmLogo = 'images/osm_logo.png'; @@ -144,7 +148,9 @@ public function parseLiteParams() } if ($_GET['maptype']) { - if (array_key_exists($_GET['maptype'], $this->tileSrcUrl)) $this->maptype = $_GET['maptype']; + $mapTypeParam = $_GET['maptype']; + if (array_key_exists($mapTypeParam, $this->mapTypeAliases)) $mapTypeParam = $this->mapTypeAliases[$mapTypeParam]; + if (array_key_exists($mapTypeParam, $this->tileSrcUrl)) $this->maptype = $mapTypeParam; } }