Browse Source

attempt to clean up map URLs

pull/10/head
Aaron Parecki 9 years ago
parent
commit
b2ec021f4b
4 changed files with 9 additions and 8 deletions
  1. +4
    -2
      controllers/controllers.php
  2. +2
    -3
      lib/helpers.php
  3. +2
    -2
      views/new-post.php
  4. +1
    -1
      views/partials/entry.php

+ 4
- 2
controllers/controllers.php View File

@ -239,11 +239,13 @@ $app->get('/options', function() use($app) {
});
$app->get('/map.png', function() use($app) {
$params = $app->request()->params();
$url = get_static_map($_SERVER['QUERY_STRING']);
$url = static_map_service($_SERVER['QUERY_STRING']);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$img = curl_exec($ch);
header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('+30 days')) . ' GMT');
header('Pragma: cache');
header('Cache-Control: private');
$app->response()['Content-type'] = 'image/png';
$app->response()->body($img);
});

+ 2
- 3
lib/helpers.php View File

@ -170,12 +170,11 @@ function get_syndication_targets(&$user) {
);
}
function static_map($latitude, $longitude, $height=174, $width=300, $zoom=14) {
#return 'http://static-maps.pdx.esri.com/img.php?marker[]=lat:' . $latitude . ';lng:' . $longitude . ';icon:small-green-cutout&basemap=topo&width=' . $width . '&height=' . $height . '&zoom=' . $zoom;
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 get_static_map($query) {
function static_map_service($query) {
return 'http://static-maps.pdx.esri.com/img.php?' . $query;
}

+ 2
- 2
views/new-post.php View File

@ -86,8 +86,8 @@ $(function(){
$("#note_location_msg").removeClass("img-visible");
}
var map_template_wide = "<?= static_map('{lat}', '{lng}', 180, 700, 15) ?>";
var map_template_small = "<?= static_map('{lat}', '{lng}', 320, 480, 15) ?>";
var map_template_wide = "<?= build_static_map_url('{lat}', '{lng}', 180, 700, 15) ?>";
var map_template_small = "<?= build_static_map_url('{lat}', '{lng}', 320, 480, 15) ?>";
function fetch_location() {
$("#note_location_loading").show();

+ 1
- 1
views/partials/entry.php View File

@ -1,7 +1,7 @@
<li class="h-entry">
<?php if($this->entry->latitude): ?>
<img src="/map.png?latitude=<?= $this->entry->latitude ?>&amp;longitude=<?= $this->entry->longitude ?>" class="map-img">
<img src="<?= build_static_map_url($this->entry->latitude, $this->entry->longitude, 174,300,14) ?>" class="map-img">
<?php endif; ?>
<div class="author h-card p-author">

Loading…
Cancel
Save