Browse Source

add option to provide custom tile URL

main
Aaron Parecki 7 years ago
parent
commit
2d2449d9e8
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 18 additions and 5 deletions
  1. +18
    -5
      p3k/geo/StaticMap.php
  2. BIN
      p3k/map/images/mapbox-attribution.png
  3. BIN
      p3k/map/images/mapbox-attribution.psd

+ 18
- 5
p3k/geo/StaticMap.php View File

@ -242,7 +242,7 @@ function generate($params, $filename, $assetPath) {
), ),
'stamen-watercolor' => array( 'stamen-watercolor' => array(
'http://tile.stamen.com/watercolor/{Z}/{X}/{Y}.png' 'http://tile.stamen.com/watercolor/{Z}/{X}/{Y}.png'
)
),
); );
if(k($params,'basemap') && k($tileServices, k($params,'basemap'))) { if(k($params,'basemap') && k($tileServices, k($params,'basemap'))) {
@ -251,6 +251,9 @@ function generate($params, $filename, $assetPath) {
$overlayURL = $tileServices[k($params,'basemap')][1]; $overlayURL = $tileServices[k($params,'basemap')][1];
else else
$overlayURL = 0; $overlayURL = 0;
} elseif(k($params, 'basemap') == 'custom') {
$tileURL = $params['tileurl'];
$overlayURL = false;
} else { } else {
$tileURL = $tileServices['gray'][0]; $tileURL = $tileServices['gray'][0];
$overlayURL = false; $overlayURL = false;
@ -258,9 +261,9 @@ function generate($params, $filename, $assetPath) {
function urlForTile($x, $y, $z, $tileURL) { function urlForTile($x, $y, $z, $tileURL) {
return str_replace(array( return str_replace(array(
'{X}', '{Y}', '{Z}'
'{X}', '{Y}', '{Z}', '{x}', '{y}', '{z}'
), array( ), array(
$x, $y, $z
$x, $y, $z, $x, $y, $z
), $tileURL); ), $tileURL);
} }
@ -300,6 +303,8 @@ function generate($params, $filename, $assetPath) {
$mh = curl_multi_init(); $mh = curl_multi_init();
$numTiles = 0; $numTiles = 0;
$urls = array();
for($x = $swTile['x']; $x <= $neTile['x']; $x++) { for($x = $swTile['x']; $x <= $neTile['x']; $x++) {
if(!array_key_exists("$x", $tiles)) { if(!array_key_exists("$x", $tiles)) {
$tiles["$x"] = array(); $tiles["$x"] = array();
@ -310,6 +315,7 @@ function generate($params, $filename, $assetPath) {
for($y = $swTile['y']; $y <= $neTile['y']; $y++) { for($y = $swTile['y']; $y <= $neTile['y']; $y++) {
$url = urlForTile($x, $y, $zoom, $tileURL); $url = urlForTile($x, $y, $zoom, $tileURL);
$urls[] = $url;
$tiles["$x"]["$y"] = false; $tiles["$x"]["$y"] = false;
$chs["$x"]["$y"] = curl_init($url); $chs["$x"]["$y"] = curl_init($url);
curl_setopt($chs["$x"]["$y"], CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($chs["$x"]["$y"], CURLOPT_RETURNTRANSFER, TRUE);
@ -525,11 +531,18 @@ function generate($params, $filename, $assetPath) {
} }
if(k($params,'attribution') == 'mapbox') {
$logo = imagecreatefrompng($assetPath . '/mapbox-attribution.png');
imagecopy($im, $logo, $width-imagesx($logo), $height-imagesy($logo), 0,0, imagesx($logo),imagesy($logo));
} elseif(k($params,'attribution') == 'mapbox-small') {
$logo = imagecreatefrompng($assetPath . '/mapbox-attribution.png');
$shrinkFactor = 2;
imagecopyresampled($im, $logo, $width-round(imagesx($logo)/$shrinkFactor), $height-round(imagesy($logo)/$shrinkFactor), 0,0, round(imagesx($logo)/$shrinkFactor),round(imagesy($logo)/$shrinkFactor), imagesx($logo),imagesy($logo));
if(k($params,'attribution') != 'none') {
} elseif(k($params,'attribution') != 'none') {
$logo = imagecreatefrompng($assetPath . '/powered-by-esri.png'); $logo = imagecreatefrompng($assetPath . '/powered-by-esri.png');
// Shrink the esri logo if the image is small
// Shrink the logo if the image is small
if($width > 120) { if($width > 120) {
if($width < 220 || k($params, 'attribution') == 'small') { if($width < 220 || k($params, 'attribution') == 'small') {
$shrinkFactor = 2; $shrinkFactor = 2;

BIN
p3k/map/images/mapbox-attribution.png View File

Before After
Width: 82  |  Height: 34  |  Size: 3.3 KiB

BIN
p3k/map/images/mapbox-attribution.psd View File


Loading…
Cancel
Save