changeset 250:ee5492ccba8e gmap2

Add configurable base URL.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 17 Mar 2014 21:55:20 +0200
parents a59e1a7f71f8
children cd489f20cf9d
files config.inc.php.example index.php map.js
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/config.inc.php.example	Mon Mar 17 20:25:22 2014 +0200
+++ b/config.inc.php.example	Mon Mar 17 21:55:20 2014 +0200
@@ -1,5 +1,6 @@
 <?php
 
+$pageBaseURL = "http://somesite.com/map/";
 $gmapsKey = "";
 $gmapsVersion = "3";
 
--- a/index.php	Mon Mar 17 20:25:22 2014 +0200
+++ b/index.php	Mon Mar 17 21:55:20 2014 +0200
@@ -30,6 +30,9 @@
 }
 $pageCSS = "css/mapstyle".$pageCSSIndex.".css";
 
+if (!isset($pageBaseURL))
+  $pageBaseURL = "";
+
 echo
   "<!DOCTYPE html>\n".
   "<html>\n".
@@ -89,10 +92,17 @@
     <script type="text/javascript" src="markers.js"></script>
     <script type="text/javascript" src="nav.js"></script>
 <?php
-  echo "    <script type=\"text/javascript\">pmapInitializeMap(";
+  echo
+    "    <script type=\"text/javascript\">\n".
+    "      pmapBaseURL = \"".$pageBaseURL."\";\n".
+    "      pmapInitializeMap(";
+
   if (isset($_GET["x"]) && isset($_GET["y"]) && isset($_GET["zoom"]))
     echo intval($_GET["x"]).",".intval($_GET["y"]).",".intval($_GET["zoom"]);
-  echo ");</script>\n";
+
+  echo
+    ");\n".
+    "    </script>\n";
 ?>
   </body>
 </html>
--- a/map.js	Mon Mar 17 20:25:22 2014 +0200
+++ b/map.js	Mon Mar 17 21:55:20 2014 +0200
@@ -1,5 +1,6 @@
 // $Id: map.js 2404 2009-12-24 20:01:32Z jeskko $
 
+var pmapBaseURL;
 var pmap;
 var pmapCanvas;
 
@@ -157,7 +158,7 @@
     var tx = Math.round(p.x) + pmapWorld.ox - 1;
     var ty = Math.round(p.y) + pmapWorld.oy;
     
-    str = "http://tnsp.org/gmap2/?x="+ tx +"&y="+ ty +"&zoom="+ pmap.getZoom();
+    str = pmapBaseURL +"?x="+ tx +"&y="+ ty +"&zoom="+ pmap.getZoom();
 
     window.prompt("Copy to clipboard: Ctrl+C, Enter", str);
   }