Browse Source

switch to local rendering of static map

dependabot/composer/firebase/php-jwt-6.0.0
Aaron Parecki 2 years ago
parent
commit
b3b3dc41bc
Failed to extract signature
3 changed files with 34 additions and 1 deletions
  1. +24
    -0
      controllers/controllers.php
  2. +2
    -0
      lib/config.template.php
  3. +8
    -1
      lib/helpers.php

+ 24
- 0
controllers/controllers.php View File

@ -898,3 +898,27 @@ $app->get('/airport-info', function() use($app){
$app->response()->body(json_encode($response));
}
});
$app->get('/map-img', function() use($app) {
$params = $app->request()->params();
$app->response()['Content-type'] = 'image/png';
$params = [
'marker[]' => 'lat:'.$params['lat'].';lng:'.$params['lng'].';icon:small-blue-cutout',
'basemap' => 'custom',
'width' => $params['w'],
'height' => $params['h'],
'zoom' => $params['z'],
'tileurl' => Config::$mapTileURL,
'token' => Config::$atlasToken,
];
$ch = curl_init('https://atlas.p3k.io/map/img');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_exec($ch);
});

+ 2
- 0
lib/config.template.php View File

@ -20,6 +20,8 @@ class Config {
public static $twitterClientID = '';
public static $twitterClientSecret = '';
public static $mapTileURL = '';
// https://developers.google.com/maps/documentation/javascript/get-api-key
public static $googleMapsAPIKey = '';
}

+ 8
- 1
lib/helpers.php View File

@ -370,7 +370,14 @@ function get_micropub_source(&$user, $url, $properties) {
}
function static_map($latitude, $longitude, $height=180, $width=700, $zoom=14) {
return 'https://atlas.p3k.io/map/img?marker[]=lat:' . $latitude . ';lng:' . $longitude . ';icon:small-blue-cutout&basemap=gray&width=' . $width . '&height=' . $height . '&zoom=' . $zoom;
$params = [
'lat' => $latitude,
'lng' => $longitude,
'h' => $height,
'w' => $width,
'z' => $zoom,
];
return '/map-img?'.http_build_query($params);
}
function relative_time($date) {

Loading…
Cancel
Save