Browse Source

refactor maps

main
Aaron Parecki 1 year ago
parent
commit
314318ef20
Failed to extract signature
3 changed files with 11 additions and 7 deletions
  1. +7
    -2
      controllers/controllers.php
  2. +3
    -0
      lib/config.template.php
  3. +1
    -5
      lib/helpers.php

+ 7
- 2
controllers/controllers.php View File

@ -355,9 +355,14 @@ $app->get('/options.json', function() use($app) {
});
$app->get('/map.png', function() use($app) {
$url = static_map_service($_SERVER['QUERY_STRING']);
$ch = curl_init($url);
$params = $app->request()->params();
$params['basemap'] = 'custom';
$params['tileurl'] = Config::$mapTileURL;
$params['token'] = Config::$atlasToken;
$ch = curl_init('https://atlas.p3k.io/map/img');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$img = curl_exec($ch);
header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('+30 days')) . ' GMT');
header('Pragma: cache');

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

@ -13,6 +13,9 @@ class Config {
public static $mf2Debug = false;
public static $atlasToken = '';
public static $mapTileURL = '';
public static $alexaClientID = '';
public static $alexaClientSecret = '';
public static $alexaRedirectURIs = [

+ 1
- 5
lib/helpers.php View File

@ -196,11 +196,7 @@ function get_micropub_config(&$user) {
}
function build_static_map_url($latitude, $longitude, $height, $width, $zoom) {
return '/map.png?marker[]=lat:' . $latitude . ';lng:' . $longitude . ';icon:small-green-cutout&basemap=topo&width=' . $width . '&height=' . $height . '&zoom=' . $zoom;
}
function static_map_service($query) {
return 'https://atlas.p3k.io/map/img?' . $query;
return '/map.png?marker[]=lat:' . $latitude . ';lng:' . $longitude . ';icon:small-green-cutout&width=' . $width . '&height=' . $height . '&zoom=' . $zoom;
}
function relative_time($date) {

Loading…
Cancel
Save