#!/usr/bin/perl # osmflipmap - a fast flipping html OSM tile browser # Copyright 2007 MJ Ray, under same terms as zlib #### SETTINGS $title = "MJR's OSM Flip Map"; $default_x = 15; $default_y = 10; $default_z = 5; # Pick a map tile server... # If you're using this a lot, it might be # nice to run some sort of image cache. %mapservers = ( 'tiles@home' => 'http://dev.openstreetmap.org/~ojw/Tiles/tile.php/', 'mapnik' => "http://tile.openstreetmap.org", 'cycle' => 'http://thunderflames.org/tiles/cycle/' # http://www.gravitystorm.co.uk/osm/ ); $default_t = 'mapnik'; #### END OF SETTINGS use CGI qw/:standard/; $q = new CGI; $x = $q->param('x'); $x = $default_x unless (defined($x)); $y = $q->param('y'); $y = $default_y unless (defined($y)); $z = $q->param('z'); $z = $default_z unless (defined($z)); $big = $q->param('big') || 0; $mapserver = $mapservers{$default_t}; $t = $q->param('t'); if (defined($t)&&defined($mapservers{$t})) { $mapserver = $mapservers{$t}; } if (defined($q->param('ll'))) { my ($Lat, $Long) = split(/,/,$q->param('ll')); $z = 12; my $Size = (2**$z); my $pi = 3.1415926535; $x = sprintf('%d',$Size * ($Long + 180) / 360); $Lat = ($Lat*$pi)/180; $y = sprintf('%d',$Size * ($pi - (log((sin($Lat)/cos($Lat)) + (1/cos($Lat))))) / (2 * $pi)); } $me = script_name(); $title .= " ($x,$y,$z,$big)"; print header(-cache_control=>'max-age=36000'), '
Copyright © 2007, various OpenStreetMap contributors (see max zoom). Some rights reserved. Licensed as Creative Commons CC-BY-SA 2.0
" .maptile(($x+$j),($y+$i),$z,$big?0:"tile") ." | "; } else { # otherwise it's a border flip link $r .= "" ."X" ." | "; } } $r .= "||
Zoom out | Big map |
---|