From 49357127f0635c4b6e7a5e962620a06a194616e9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 2 Oct 2011 21:47:59 -0400 Subject: Add Open Steet Map support to gpsd.php. Showed up as a patch on Berlios from 'petschge', 2011-Jan-07 14:38. Found while cleaning up after the move to Savannah. --- gpsd.php.in | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 10 deletions(-) (limited to 'gpsd.php.in') diff --git a/gpsd.php.in b/gpsd.php.in index ea0466f6..adb749a6 100644 --- a/gpsd.php.in +++ b/gpsd.php.in @@ -14,7 +14,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -global $head, $blurb, $title, $googlemap, $autorefresh, $footer, $gmap_key; +global $head, $blurb, $title, $showmap, $autorefresh, $footer, $gmap_key; global $server, $advertise, $port, $open, $swap_ew, $testmode; $testmode = 1; # leave this set to 1 @@ -323,7 +323,7 @@ function dfix($x, $y, $z){ function write_html($resp){ global $sock, $errstr, $errno, $server, $port, $head, $body, $open; - global $blurb, $title, $autorefresh, $googlemap, $gmap_key, $footer; + global $blurb, $title, $autorefresh, $showmap, $gmap_key, $footer; global $testmode, $advertise; $GPS = json_decode($resp, true); @@ -345,11 +345,15 @@ function write_html($resp){ else $autorefresh = ''; - $gmap_head = $gmap_body = $gmap_code = ''; - if ($googlemap){ - $gmap_head = gen_gmap_head(); - $gmap_body = 'onload="Load()" onunload="GUnload()"'; - $gmap_code = gen_gmap_code(); + $map_head = $map_body = $map_code = ''; + if ($showmap == 1) { + $map_head = gen_gmap_head(); + $map_body = 'onload="Load()" onunload="GUnload()"'; + $map_code = gen_map_code(); + } else if ($showmap == 2) { + $map_head = gen_osm_head(); + $map_body = 'onload="Load()"'; + $map_code = gen_map_code(); } $part1 = << @@ -358,7 +362,7 @@ function write_html($resp){ {$head} -{$gmap_head} +{$map_head} {$title} - GPSD Test Station {$lat}, {$lon} @@ -384,7 +388,7 @@ function write_html($resp){ - +
@@ -510,7 +514,7 @@ function write_config(){ #\$advertise = 'localhost'; \$port = 2947; \$autorefresh = 0; # number of seconds after which to refresh -\$googlemap = 0; # set to 1 if you want to have a google map +\$showmap = 0; # set to 1 if you want to have a google map, set it to 2 if you want a map based on openstreetmap \$gmap_key = 'GetYourOwnGoogleKey'; # your google API key goes here \$swap_ew = 0; # set to 1 if you don't understand projections \$open = 0; # set to 1 to show the form to change the GPSd server @@ -580,6 +584,50 @@ EOT; } +function gen_osm_head() { +global $GPS; +return << + + +EOT; +} + function gen_gmap_code() { return << -- cgit v1.2.1