From 6224053447063bbbd34f0a07314963b0028f1791 Mon Sep 17 00:00:00 2001 From: expoonserver Date: Sun, 11 Aug 2013 21:03:59 +0100 Subject: [PATCH] Add basic slippy map implementation. Needs apache config to keep torggle out of this dir. ents.gpx file should really come from elsewhere once this is working. The javascript link should point to /usr/share/javascript which contains openlayers (from libjs-openlayers) --- map/ents.gpx | 387 +++++++++++++++++++++++++++++++++++++++++++++++++ map/index.html | 120 +++++++++++++++ map/javascript | 1 + map/map.css | 102 +++++++++++++ map/util.js | 277 +++++++++++++++++++++++++++++++++++ 5 files changed, 887 insertions(+) create mode 100644 map/ents.gpx create mode 100644 map/index.html create mode 120000 map/javascript create mode 100644 map/map.css create mode 100644 map/util.js diff --git a/map/ents.gpx b/map/ents.gpx new file mode 100644 index 000000000..08c570e6b --- /dev/null +++ b/map/ents.gpx @@ -0,0 +1,387 @@ + + +1675.46103.1 +1702.30113.sumpf.8_10 +1660.32142.45 +1757.62143.canyon.b0 +1757.83143.p143 +1734.28145.p145a +1731.76145.p145b +1813.222002-03to2004-15.6 +1841.332002-03to2004-15.p2002-03 +1807.242002-03to2004-15.p2004-15a +1802.632004-15to2004-14.p2004-14 +1807.242004-15to2004-14.p2004-15a +1867.142004-18to2006-09.p2004-18 +1912.432004-18to2006-09.p2006-09 +1905.082004-18to2006-09.p258a +1910.232004-18to2006-09.p258b +1738.382006-06.4 +1731.122006-06.7 +1726.842007-neu.1 +1909.802010-03.1 +1919.282012-ns-03.1 +1905.272012-ns-10.1 +1940.80233.1 +1830.48234to2002-03.1 +1838.80234to2002-03.3 +1843.05234to2002-03.5 +1841.33234to2002-03.9 +1807.96243.5 +1946.79bs16 +1925.79bs17 +1936.79bs19 +1976.79casino.0 +1941.80e02.0 +1956.80e09.0 +1931.80e10.0 +1876.81e28.0 +1946.81gps02.p2002-10 +1906.81gps02.p2002-ad-01 +1903.81gps02.p2002-ad-02 +1924.81gps02.p2002-ad-03 +1948.81gps02.p2002-ad-04 +1946.81gps02.p2002-x09 +1946.81gps02.p2002-x09b +1846.80gps02.p2002-x15 +1846.81gps02.p2002-x16 +1846.81gps02.p2002-x17 +1846.81gps02.p2002-x18 +1946.80gps02.p2005-05 +1946.80gps02.p2005-06 +1946.80gps02.p2005-08 +1781.82gps02olly.2001-06 +1795.83gps02olly.2001-07 +1794.83gps02olly.2001-08 +1773.83gps02olly.2001-09 +1768.83gps02olly.2001-10 +1749.83gps02olly.2001-11 +1732.83gps02olly.2001-12 +1746.82gps02olly.2002-ob-01 +1746.82gps02olly.2002-w-01 +1773.82gps02olly.235 +1798.83gps02olly.236 +1823.83gps02olly.237 +1781.82gps02olly.238 +1777.82gps02olly.88f +1796.82gps02olly.cliffhole +1772.83gps02olly.hfg-ka88 +1821.81gps03.2003-07 +2046.81gps03_bis.p2003-x11 +2046.81gps03_bis.p2003-x12 +2046.81gps03_bis.p2003-x13 +2046.81gps03_bis.p2003-x14 +2046.81gps03_bis.p2003-x15 +2046.81gps03_bis.p2003-x16 +2046.81gps03_bis.p2003-x17 +2046.81gps03_bis.p2003-x18 +1846.81gps04.p2004-10 +1750.81gps04.p2004-12 +1741.81gps04.p2004-13 +1877.81gps04.p2004-16 +1880.81gps04.p2004-17 +1867.14gps04.p2004-18 +1806.81gps04.p2004-21 +1918.81gps04.p247 +1819.82gps06.2006-01 +1753.82gps06.2006-02 +1752.82gps06.2006-03 +1847.81gps06.2006-05 +1914.81gps06.2006-07 +46.82gps98.1996_05 +1646.83gruenstein.1 +1922.80haldenloch.eingang.0 +1871.79lou-toti.lt-eingang.1 +1885.79lunge.ent +1726.84neuerschacht.12 +840.86p1 +1686.89p100 +1674.70p101a +1707.20p104 +1692.89p105 +1693.66p106 +1708.07p107 +1681.40p108 +1643.29p109 +1727.26p111 +1726.60p112 +1688.33p113 +1535.12p115 +1458.06p115b +1544.97p115c +1709.83p116 +1656.80p131 +1830.61p135 +1842.43p136 +1836.31p136b +1837.68p136c +1839.33p136d +1842.07p138 +1873.97p139 +1669.95p141 +1758.27p144 +1745.56p144b +1700.35p148 +1649.18p150 +1646.07p151 +1639.24p152 +1790.51p153 +1817.87p154 +1809.65p154b +1797.23p155 +1841.01p156 +1731.12p157 +1761.32p158 +1684.70p160 +1834.54p161 +1799.32p161b +1799.47p161c +1661.04p161d +1706.53p161e +1707.02p161f +1764.89p161g +1735.50p161h +1794.24p162 +1800.51p162b +1773.37p163 +1672.52p164rig +1839.46p165 +1682.76p171b +1677.85p172 +1706.11p174 +1706.45p175 +1715.21p176 +1486.86p18 +1813.46p180 +1643.89p182 +1638.58p183 +1638.33p184 +1810.28p185 +1748.08p186 +1676.30p188 +1811.14p191 +1791.05p193 +1809.58p194 +1825.67p195 +1837.71p196 +1700.63p1976_b4 +1746.61p1987-02 +1848.42p199 +1678.65p1998-x01 +1861.38p2000-08 +1856.82p2001-02 +1849.61p2001-03 +1907.58p2002-05 +1907.81p2002-06 +1875.94p2002-07 +1863.31p2002-08 +1699.01p2002-w-02 +1911.81p2003-01 +1689.13p2004-01 +1692.63p2004-02 +1677.59p2004-03 +1697.55p2004-07 +1695.07p2004-08 +1710.37p2004-13 +1802.63p2004-14 +1867.14p2004-18 +1810.53p2004-19a +1813.39p2004-19b +1816.02p2004-19c +1860.70p2004-20 +1764.04p2005-01 +1802.05p2005-02 +1731.04p2005-03 +1846.80p2005-07 +1695.14p2005-91 +1682.07p2005-92 +1678.85p2005-93 +1681.80p2005-94 +1682.13p2005-95 +1680.45p2005-96 +1683.39p2005-97 +1682.71p2005-98 +1675.43p2005-99 +1837.25p2006-08 +1697.64p2006-70 +1694.09p2006-71 +1747.45p2006-72 +1689.93p2006-73 +1907.81p2007-01 +1892.81p2007-02 +1793.82p2007-03 +1915.81p2007-04 +1796.81p2007-04a +1804.81p2007-05 +1856.81p2007-06 +1919.81p2007-07 +1955.80p2007-11 +1829.81p2007-12 +1688.06p2007-70 +1688.40p2007-71 +1692.87p2007-72 +1934.81p2009-01 +1918.80p2009-02 +1933.80p2009-03 +1932.81p2009-04 +1826.29p201 +1820.02p2010-01 +1905.80p2010-02 +1912.80p2010-03 +1906.80p2010-04 +1931.80p2010-05 +1896.79p2010-06 +1984.80p2011-01 +1725.75p2012-70 +1715.77p2012-70b +1726.91p2012-70c +1935.80p2012-dd-01 +1925.80p2012-dd-02 +1925.80p2012-dd-03 +2003.80p2012-dd-04 +1940.79p2012-dd-05 +1927.79p2012-dd-06 +1930.79p2012-dd-07 +1948.80p2012-dd-08 +1973.80p2012-dd-09 +1932.79p2012-dd-10 +1877.79p2012-dd-11 +1948.81p2012-hw-01 +1919.81p2012-hw-02 +1861.81p2012-ns-01 +1922.80p2012-ns-02 +1921.80p2012-ns-03 +1913.80p2012-ns-05 +1916.80p2012-ns-06 +1922.80p2012-ns-07 +1928.80p2012-ns-08 +1934.80p2012-ns-09 +1909.80p2012-ns-10 +1923.80p2012-ns-11 +1925.80p2012-ns-12 +1931.80p2012-ns-13 +1934.80p2012-ns-14 +1921.80p2012-ns-15 +1939.80p2012-ok-01 +1944.80p2012-ok-02 +1925.79p2012-ok-03 +1682.51p202 +1757.96p203 +1859.21p204a +1877.93p204c +1861.44p204e +1865.61p204f +1823.45p204g +1833.74p204h +1834.08p204i +1811.69p205 +1745.82p206 +1711.05p207 +1707.80p208 +1839.71p209 +1869.23p214 +1691.98p215a +1696.63p215b +1697.78p216 +1695.09p217 +1826.00p218 +1832.44p219 +1733.83p220 +1854.03p222 +1860.46p223 +1849.77p224 +1784.83p225 +1671.61p226a +1669.81p226b +1672.32p227 +1646.80p228 +1710.10p229 +1851.82p230 +1861.93p231a +1862.00p231b +1870.00p231c +1861.90p231d +1864.00p231e +1866.03p231f +1866.83p231g +1861.85p231h +1858.56p231i +1946.80p232 +1830.48p234a +1838.80p234b +1879.33p239 +1837.81p240 +1890.31p241 +1881.87p242 +1877.90p244 +1781.71p245 +1834.81p246 +1911.81p248 +1843.05p249 +1684.65p250 +1905.08p258a +1910.23p258b +1629.13p31 +1614.77p32 +1705.51p36 +1736.31p40a +1689.11p40e +1735.46p40f +1693.72p40h +1698.72p40s +1668.43p41a +1682.02p41b +1700.61p75 +1693.66p76 +1692.36p76a +1694.10p76b +1713.13p78a +1706.42p78b +1713.05p78d +1729.20p78e +1713.09p80 +1703.86p81 +1702.02p81b +1704.69p82 +1710.55p82b +1717.34p83 +1704.14p85 +1589.31p87 +1692.84p88 +1716.44p90 +1687.16p91 +1685.02p93 +1677.28p94 +1645.84p95 +1641.84p96 +1685.17p97 +1721.77p98 +1688.32p99 +1677.43p99ob02 +1810.68pmi5 +1869.61pquarriesd +1714.14pwk12 +1881.79raetsel.ent +1896.79sternloch.ent +1676.28t101 +1675.26t102 +1675.46t103 +1820.84t147 +1841.08t156 +1694.09t159 +1677.78t171 +1683.39t173 +1674.00t189 +1672.76t190 +1685.37t197 +1677.51t198 +1690.89t200 +1807.24t2004-15a +1813.99t2004-15b +1858.19t204b +1819.08t204d +1673.25t210 +1799.25t251 +1546.82tantalus +1906.80upsidedown.8 + diff --git a/map/index.html b/map/index.html new file mode 100644 index 000000000..027d4c121 --- /dev/null +++ b/map/index.html @@ -0,0 +1,120 @@ + + + +Loser cave map + + + + + + + + + + + + + + +
Show map information
+
Expo prototype slippy map
Please mouseover
the pin markers.
+
+

If you see this text, you opened the map HTML-File without the necessary files.

+ + diff --git a/map/javascript b/map/javascript new file mode 120000 index 000000000..e3b95b482 --- /dev/null +++ b/map/javascript @@ -0,0 +1 @@ +/usr/share/javascript \ No newline at end of file diff --git a/map/map.css b/map/map.css new file mode 100644 index 000000000..cff1c602b --- /dev/null +++ b/map/map.css @@ -0,0 +1,102 @@ +@charset "utf-8"; + +html,body { + background-color: #FFF; + height: 100%; + width: 100%; + margin: 0; + padding: 0; + font-family: Verdana, Arial, sans-serif; + font-size: 1em; + overflow: hidden; + color: #000; +} + +a { + color: #0000FF; + text-decoration: none; +} + +a:hover { + color: #000011; + text-decoration: underline; +} + +#map { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + font-family: Arial, sans-serif; + font-size: 1em; + color: #000; +} +.olFramedCloudPopupContent { + font-size: 0.8em; + font-family: Verdana, sans-serif; +} +#descriptionToggle { + position: absolute; + font-size: 1em; + z-index: 10000; + left: 80px; + height: 14px; + border-left: 1px solid #000040; + border-bottom: 1px solid #000040; + border-right: 1px solid #000040; + padding: 2px 10px; + margin-right: 200px; + background-color: #EEE; + font-size: 12px; + cursor: default; + opacity: 0.7; +} +#descriptionToggle:hover { + background-color: #FFF; + opacity: 1; +} +#description { + position: absolute; + z-index: 10000; + left: 80px; + top: 18px; + border: 1px solid #000040; + padding: 10px 10px; + margin-right: 200px; + background-color: #FFF; + font-size: 12px; +} + +#attribution { + bottom: 0; + left: 0; + padding: 5px 8px 1px 8px; + position: absolute; + font-size: 11px; + font-style: italic; + z-index: 1000; +} + +#layer { + position: absolute; + top: 60px; + right: 10px; + z-index: 10002; +} + +#layer > div { + border: 1px solid #000; + background-color: #FFF; + padding: 4px 5px; + font-size: 0.7em; + cursor: default; + margin-bottom: 4px; + +} +#layer div:hover { +} +#layer .active { + background-color: #EEF; +} + +.hide { display: none; } diff --git a/map/util.js b/map/util.js new file mode 100644 index 000000000..dbb27c3af --- /dev/null +++ b/map/util.js @@ -0,0 +1,277 @@ +/* + * Einige Funktionen die ursprünglich von http://wiki.openstreetmap.org/wiki/DE:Karte_in_Webseite_einbinden stammen, + * teilweise modifiziert + * + * Some functions from the example at http://wiki.openstreetmap.org/wiki/DE:Karte_in_Webseite_einbinden, some + * slightly modified + */ +function jumpTo(lon, lat, zoom) { + var x = Lon2Merc(lon); + var y = Lat2Merc(lat); + map.setCenter(new OpenLayers.LonLat(x, y), zoom); + return false; +} + +function Lon2Merc(lon) { + return 20037508.34 * lon / 180; +} + +function Lat2Merc(lat) { + var PI = 3.14159265358979323846; + lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180); + return 20037508.34 * lat / 180; +} + +function addMarker(layer, lon, lat, popupContentHTML, showPopupOnLoad, iconId) { + + // Koordinaten in LonLat umwandeln + var ll = new OpenLayers.LonLat(Lon2Merc(lon), Lat2Merc(lat)); + + // Feature erstellen und konfigurieren (Popup und Marker) + var feature = new OpenLayers.Feature(layer, ll); + feature.closeBox = true; + feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {minSize: new OpenLayers.Size(200, 120) } ); + feature.data.popupContentHTML = popupContentHTML; + feature.data.overflow = "auto"; + feature.data.icon = makeIcon(iconId); + + // Marker erstellen + var marker = feature.createMarker(); + + /* + * Handler Funktionen für die Mouse-Events + */ + // Click + var markerClick = function(evt) { + // Wenn das Popup nicht sichtbar ist, dann kann es nicht fest sichtbar sein + if (!this.popup.visible()) + this.popup.clicked = false; + if (this.popup.clicked == true) { + this.popup.clicked = false; + this.popup.hide(); + } + else { + this.popup.clicked = true; + if (!this.popup.visible()) + this.popup.show(); + } + OpenLayers.Event.stop(evt); + }; + // Hover + var markerHover = function(evt) { + // Wenn das Popup nicht sichtbar ist, dann kann es nicht fest sichtbar sein + if (!this.popup.visible()) + this.popup.clicked = false; + if (!this.popup.clicked) + this.popup.show(); + + OpenLayers.Event.stop(evt); + } + // Hover End + var markerHoverEnd = function(evt) { + if (!this.popup.clicked) { + this.popup.hide(); + } + OpenLayers.Event.stop(evt); + } + + // Events auf den Marker registrieren und als Objekt das Feature übergeben + marker.events.register("mousedown", feature, markerClick); + if (showPopupOnHover) { + marker.events.register("mouseover", feature, markerHover); + marker.events.register("mouseout", feature, markerHoverEnd); + } + + // Erstellten Marker der Ebene hinzufügen + layer.addMarker(marker); + + // Popup erstellen, der Karte hinzufügen und anzeigen, falls gewünscht + map.addPopup(feature.createPopup(feature.closeBox)); + + if (showPopupOnLoad != true) { + // Wenn das Popup nicht angezeigt werden soll, verstecken und auf 'nicht angeklickt' setzen + feature.popup.hide(); + feature.popup.clicked = false; + } else { + // Das Popup wird direkt angezeigt und zwar solange bis man es explizit schließt + feature.popup.clicked = true; + } + + return marker; +} + +/* + * + * Creates a new marker icon + * + * using the icons-array (defined in the html-file) + * + * index + * 0 address to the image + * 1 width of the image + * 2 height + * 3 factor by which the image should be offset horizontally + * 4 factor by which the image should be offset vertically + * + * please see the icon array itself for examples of values + */ +function makeIcon(iconId) { + var size = new OpenLayers.Size(icons[iconId][1],icons[iconId][2]); + var offset = new OpenLayers.Pixel(-(size.w*icons[iconId][3]), -(size.h*icons[iconId][4])); + var icon = new OpenLayers.Icon(icons[iconId][0],size,offset); + return icon; +} + +function getCycleTileURL(bounds) { + var res = this.map.getResolution(); + var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); + var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); + var z = this.map.getZoom(); + var limit = Math.pow(2, z); + + if (y < 0 || y >= limit) + { + return null; + } + else + { + x = ((x % limit) + limit) % limit; + + return this.url + z + "/" + x + "/" + y + "." + this.type; + } +} + +/* + * Funktion zum Zerlegen der URL um die Parameter zu erhalten (für den Permalink) + * Splits the URL in its parameters + */ +function get_parameters() { + // erzeugt für jeden in der url übergebenen parameter einen wert + // bsp: x.htm?nachname=Munch&vorname=Alex&bildfile=wasserfall.jpg erzeugt + // variable nachname mit wert Munch und + // variable vorname mit wert Alex + // variable bildfile mit wert wasserfall.jpg + var hier = document.URL; + var parameterzeile = hier.substr((hier.indexOf("?")+1)); + var trennpos; + var endpos; + var paramname; + var paramwert; + var parameters = new Object(); + while (parameterzeile != "") { + trennpos = parameterzeile.indexOf("="); + endpos = parameterzeile.indexOf("&"); + if (endpos < 0) { endpos = 500000; } + paramname = parameterzeile.substr(0,trennpos); + paramwert = parameterzeile.substring(trennpos+1,endpos); + parameters[paramname] = paramwert; + //eval (paramname + " = \"" + paramwert + "\""); + parameterzeile = parameterzeile.substr(endpos+1); + } + return parameters; +} + +/* + * Wie der Name schon sagt ebenfalls für den Permalink, überprüft ob die Parameter in der URL gefunden wurden und überschreibt + * sie gegebenenfalls. + * Checks the url for parameters of the permalink and overwrites the default values if necessary. + */ +function checkForPermalink() { + var parameters = get_parameters(); + + if (parameters['zoom'] != null) + zoom = parseInt(parameters['zoom']); + if (parameters['lat'] != null) + lat = parseFloat(parameters['lat']); + if (parameters['lon'] != null) + lon = parseFloat(parameters['lon']); +} +/* + * Debugging Funktion + */ +function var_dump(obj) { + if(typeof obj == "object") { + return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj; + } else { + return "Type: "+typeof(obj)+"\nValue: "+obj; + } +}//end function var_dump + + + +/* + * Für den Layer-Switcher mit Buttons + */ +function setLayer(id) { + if (document.getElementById("layer") != null) { + for (var i=0;i