[tarent-useful-scripts SCM] {mirkarte} branch master updated. b955f9243a58e8486373b732dca208ddd6eb10a6

mirabilos at evolvis.org mirabilos at evolvis.org
Fri Nov 3 16:27:19 CET 2017 • <20171103152719.6449D4A019A@evolvis.org>


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MirKarte source code repository".

The branch, master has been updated
       via  b955f9243a58e8486373b732dca208ddd6eb10a6 (commit)
       via  2051a7cc24e98d80311b1f98ee6b8d89aca4e51f (commit)
      from  a08de508780e7dbe9c4959294461cb969148b5ee (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b955f9243a58e8486373b732dca208ddd6eb10a6
Author: mirabilos <t.glaser at tarent.de>
Date:   Fri Nov 3 16:27:12 2017 +0100

    hook up GPS

commit 2051a7cc24e98d80311b1f98ee6b8d89aca4e51f
Author: mirabilos <t.glaser at tarent.de>
Date:   Fri Nov 3 16:24:55 2017 +0100

    add leaflet-gps
    
    commit 059f484a62d6aa9d53a3abf9bd42ea79cdc1efa5
    from git at github.com:stefanocudini/leaflet-gps.git

-----------------------------------------------------------------------

Summary of changes:
 index.htm                                 |   7 +
 {img => leaflet-compass}/compass-icon.png | Bin
 leaflet-compass/compass-icon.svg          | 106 +++++++++++
 leaflet-compass/leaflet-compass.css       |   2 +-
 leaflet-gps/gps-icon.png                  | Bin 0 -> 2081 bytes
 leaflet-gps/gps-icon.svg                  | 299 ++++++++++++++++++++++++++++++
 leaflet-gps/leaflet-gps.css               |  56 ++++++
 leaflet-gps/leaflet-gps.js                | 226 ++++++++++++++++++++++
 8 files changed, 695 insertions(+), 1 deletion(-)
 rename {img => leaflet-compass}/compass-icon.png (100%)
 create mode 100644 leaflet-compass/compass-icon.svg
 create mode 100644 leaflet-gps/gps-icon.png
 create mode 100644 leaflet-gps/gps-icon.svg
 create mode 100644 leaflet-gps/leaflet-gps.css
 create mode 100644 leaflet-gps/leaflet-gps.js

diff --git a/index.htm b/index.htm
index 096d056..474de2b 100644
--- a/index.htm
+++ b/index.htm
@@ -7,6 +7,7 @@
  <title>MirKarte (Beta)</title>
  <link rel="stylesheet" type="text/css" href="leaflet/leaflet.css" />
  <link rel="stylesheet" type="text/css" href="leaflet-compass/leaflet-compass.css" />
+ <link rel="stylesheet" type="text/css" href="leaflet-gps/leaflet-gps.css" />
  <style type="text/css"><!--/*--><![CDATA[/*><!--*/
   #nomap {
 	padding:12px;
@@ -46,6 +47,7 @@
  /*]]>*/--></style>
  <script type="text/javascript" src="leaflet/leaflet-src.js"></script>
  <script type="text/javascript" src="leaflet-compass/leaflet-compass.js"></script>
+ <script type="text/javascript" src="leaflet-gps/leaflet-gps.js"></script>
  <script type="text/javascript" src="prototype/prototype.js"></script>
  <script type="text/javascript" src="togeojson/togeojson.js"></script>
  <script type="text/javascript" src="zip.js/WebContent/zip.js"></script>
@@ -56,6 +58,11 @@
 	var compass = new L.Control.Compass();
 	map.addControl(compass);
 	compass.activate();
+
+	var gpsctl = new L.Control.Gps({
+		"title": "Centre map on your location"
+	});
+	map.addControl(gpsctl);
   };
  //--><!]]></script>
  <script type="text/javascript" src="mirkarte.js"></script>
diff --git a/img/compass-icon.png b/leaflet-compass/compass-icon.png
similarity index 100%
rename from img/compass-icon.png
rename to leaflet-compass/compass-icon.png
diff --git a/leaflet-compass/compass-icon.svg b/leaflet-compass/compass-icon.svg
new file mode 100644
index 0000000..5b56639
--- /dev/null
+++ b/leaflet-compass/compass-icon.svg
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   height="32"
+   width="32"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.47 r22583"
+   sodipodi:docname="compass-icon.svg"
+   inkscape:export-filename="/home/z4k/www/maps/leaflet-compass/images/compass-icon.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <metadata
+     id="metadata20">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs18">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 13 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="26 : 13 : 1"
+       inkscape:persp3d-origin="13 : 8.6666667 : 1"
+       id="perspective22" />
+    <inkscape:perspective
+       id="perspective5368"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+  </defs>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1335"
+     inkscape:window-height="716"
+     id="namedview16"
+     showgrid="false"
+     inkscape:zoom="12.836708"
+     inkscape:cx="22.267484"
+     inkscape:cy="15.290523"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg2"
+     showguides="true"
+     inkscape:guide-bbox="true" />
+  <g
+     id="g3650"
+     transform="matrix(1.3445092,0,0,1.3445092,-1.4914816,-1.6752371)">
+    <path
+       transform="matrix(0.96665003,0,0,0.96665003,0.43386864,0.43842661)"
+       d="m 24.071592,13.146237 c 0,6.109389 -4.952637,11.062026 -11.062026,11.062026 -6.109388,0 -11.0620257,-4.952637 -11.0620257,-11.062026 0,-6.1093879 4.9526377,-11.0620257 11.0620257,-11.0620257 6.109389,0 11.062026,4.9526378 11.062026,11.0620257 z"
+       sodipodi:ry="11.062026"
+       sodipodi:rx="11.062026"
+       sodipodi:cy="13.146237"
+       sodipodi:cx="13.009566"
+       id="path2816"
+       style="color:#000000;fill:#ffffff;fill-opacity:0.71936759;fill-rule:evenodd;stroke:#000000;stroke-width:1.0345006;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       sodipodi:type="arc" />
+    <g
+       id="g3639">
+      <path
+         style="color:#000000;fill:#ffffff;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         d="M 13.009566,4.2239924 16.111228,13.146238 13.009566,22.068483 9.9079036,13.146238 13.009566,4.2239924 z"
+         id="rect2818" />
+      <path
+         id="path3593"
+         d="m 13.009566,5.7261651 1.778842,5.1182639 -3.557684,0 1.778842,-5.1182639 z"
+         style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.24399114;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         sodipodi:nodetypes="cccc" />
+      <path
+         sodipodi:type="arc"
+         style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         id="path3627"
+         sodipodi:cx="12.917373"
+         sodipodi:cy="13.413136"
+         sodipodi:rx="1.0190678"
+         sodipodi:ry="1.0190678"
+         d="m 13.93644,13.413136 c 0,0.562815 -0.456252,1.019067 -1.019067,1.019067 -0.562816,0 -1.019068,-0.456252 -1.019068,-1.019067 0,-0.562816 0.456252,-1.019068 1.019068,-1.019068 0.562815,0 1.019067,0.456252 1.019067,1.019068 z"
+         transform="translate(0.0921936,-0.26689816)" />
+    </g>
+  </g>
+</svg>
diff --git a/leaflet-compass/leaflet-compass.css b/leaflet-compass/leaflet-compass.css
index 08ed0e4..f7837c8 100644
--- a/leaflet-compass/leaflet-compass.css
+++ b/leaflet-compass/leaflet-compass.css
@@ -27,7 +27,7 @@
 	height: 32px;
 	width: 32px;
 	margin: 2px;
-	background: url('../img/compass-icon.png') center center no-repeat;
+	background: url('compass-icon.png') center center no-repeat;
 }
 
 .leaflet-compass .compass-digit {
diff --git a/leaflet-gps/gps-icon.png b/leaflet-gps/gps-icon.png
new file mode 100644
index 0000000..703c0db
Binary files /dev/null and b/leaflet-gps/gps-icon.png differ
diff --git a/leaflet-gps/gps-icon.svg b/leaflet-gps/gps-icon.svg
new file mode 100644
index 0000000..611486f
--- /dev/null
+++ b/leaflet-gps/gps-icon.svg
@@ -0,0 +1,299 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.1"
+   width="24"
+   height="76"
+   id="svg2"
+   inkscape:version="0.48.5 r10040"
+   sodipodi:docname="gps-icon.svg"
+   inkscape:export-filename="/home/z4k/www/maps/leaflet-gps/images/gps-icon.png"
+   inkscape:export-xdpi="102.05368"
+   inkscape:export-ydpi="102.05368">
+  <metadata
+     id="metadata23">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1205"
+     inkscape:window-height="975"
+     id="namedview21"
+     showgrid="false"
+     inkscape:zoom="6.9532167"
+     inkscape:cx="18.724505"
+     inkscape:cy="23.977181"
+     inkscape:window-x="671"
+     inkscape:window-y="39"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="target-icon-svg" />
+  <defs
+     id="defs4">
+    <style
+       type="text/css"
+       id="style6">
+      .layout {
+        stroke-width: 5;
+        stroke-linejoin: round;
+        stroke: #000000;
+        stroke-opacity: 1;
+        fill: none;
+        stroke-linecap: round;
+      }
+      .redpoint {
+        fill: red;
+        stroke: none;
+        display: none;
+      }
+
+      .layout:hover {
+        stroke-opacity: 0.4;
+      }
+      .active .redpoint {
+        display: block; 
+      }
+    </style>
+    <style
+       id="style6-3"
+       type="text/css">
+      .layout {
+        stroke-width: 5;
+        stroke-linejoin: round;
+        stroke: #000000;
+        stroke-opacity: 1;
+        fill: none;
+        stroke-linecap: round;
+      }
+      .redpoint {
+        fill: red;
+        stroke: none;
+        display: none;
+      }
+
+      .layout:hover {
+        stroke-opacity: 0.4;
+      }
+      .active .redpoint {
+        display: block; 
+      }
+    </style>
+  </defs>
+  <g
+     id="target-icon-svg"
+     class=""
+     transform="translate(0,28)">
+    <circle
+       cx="24"
+       cy="24"
+       r="5"
+       class="redpoint"
+       id="circle19"
+       sodipodi:cx="24"
+       sodipodi:cy="24"
+       sodipodi:rx="5"
+       sodipodi:ry="5"
+       style="fill:#ff0000;stroke:none;display:none"
+       d="m 29,24 c 0,2.761424 -2.238576,5 -5,5 -2.761424,0 -5,-2.238576 -5,-5 0,-2.761424 2.238576,-5 5,-5 2.761424,0 5,2.238576 5,5 z" />
+    <g
+       style="stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none"
+       class="active"
+       id="target-icon-svg-5"
+       transform="matrix(0.94022974,0,0,0.94022974,29.563243,-80.999311)">
+      <circle
+         transform="matrix(0.68474576,0,0,0.68474576,-35.145762,108.04068)"
+         style="fill:#ff0000;stroke:none;display:block"
+         id="circle19-7"
+         class="redpoint"
+         r="5"
+         cy="24"
+         cx="24"
+         sodipodi:cx="24"
+         sodipodi:cy="24"
+         sodipodi:rx="5"
+         sodipodi:ry="5"
+         d="m 29,24 c 0,2.761424 -2.238576,5 -5,5 -2.761424,0 -5,-2.238576 -5,-5 0,-2.761424 2.238576,-5 5,-5 2.761424,0 5,2.238576 5,5 z" />
+    </g>
+    <g
+       id="g3940">
+      <circle
+         inkscape:export-ydpi="99.45063"
+         inkscape:export-xdpi="99.45063"
+         inkscape:export-filename="/home/z4k/www/maps/leaflet-gps/images/g3902.png"
+         transform="matrix(0.52090395,0,0,0.52090395,-0.53190286,-28.457764)"
+         d="M 41,24 C 41,33.388841 33.388841,41 24,41 14.611159,41 7,33.388841 7,24 7,14.611159 14.611159,7 24,7 c 9.388841,0 17,7.611159 17,17 z"
+         sodipodi:ry="17"
+         sodipodi:rx="17"
+         sodipodi:cy="24"
+         sodipodi:cx="24"
+         style="fill:none;stroke:#000000;stroke-width:2.87960958;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+         id="circle9"
+         class="layout"
+         r="17"
+         cy="24"
+         cx="24" />
+      <g
+         inkscape:export-ydpi="99.45063"
+         inkscape:export-xdpi="99.45063"
+         style="stroke-width:1.45991993;stroke-miterlimit:4;stroke-dasharray:none"
+         transform="matrix(1.0012467,0,0,1.0012467,0.06626665,-0.22496325)"
+         id="g3902">
+        <path
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 1.6430699,-15.711519 4.7285567,0"
+           id="path3846"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc" />
+        <path
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3896"
+           d="m 11.888704,-5.4658847 0,-4.7285563"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           inkscape:transform-center-y="7.8813561" />
+        <path
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 22.134338,-15.711519 -4.728556,0"
+           id="path3898"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc"
+           inkscape:transform-center-x="-7.881356" />
+        <path
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3900"
+           d="m 11.888704,-25.957153 0,4.728556"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           inkscape:transform-center-y="-7.881356" />
+      </g>
+    </g>
+    <g
+       id="g3932">
+      <circle
+         cx="24"
+         cy="24"
+         r="17"
+         class="layout"
+         id="circle3920"
+         style="fill:none;stroke:#000000;stroke-width:2.87960958;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+         sodipodi:cx="24"
+         sodipodi:cy="24"
+         sodipodi:rx="17"
+         sodipodi:ry="17"
+         d="M 41,24 C 41,33.388841 33.388841,41 24,41 14.611159,41 7,33.388841 7,24 7,14.611159 14.611159,7 24,7 c 9.388841,0 17,7.611159 17,17 z"
+         transform="matrix(0.52090395,0,0,0.52090395,-0.53190286,23.533695)"
+         inkscape:export-filename="/home/z4k/www/maps/leaflet-gps/images/g3902.png"
+         inkscape:export-xdpi="99.45063"
+         inkscape:export-ydpi="99.45063" />
+      <g
+         id="g3922"
+         transform="matrix(1.0012467,0,0,1.0012467,0.06626665,51.766496)"
+         style="stroke-width:1.45991993;stroke-miterlimit:4;stroke-dasharray:none"
+         inkscape:export-xdpi="99.45063"
+         inkscape:export-ydpi="99.45063">
+        <path
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3924"
+           d="m 1.6430699,-15.711519 4.7285567,0"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+        <path
+           inkscape:transform-center-y="7.8813561"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 11.888704,-5.4658847 0,-4.7285563"
+           id="path3926"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc" />
+        <path
+           inkscape:transform-center-x="-7.881356"
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3928"
+           d="m 22.134338,-15.711519 -4.728556,0"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+        <path
+           inkscape:transform-center-y="-7.881356"
+           style="fill:none;stroke:#000000;stroke-width:1.45991993;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 11.888704,-25.957153 0,4.728556"
+           id="path3930"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc" />
+      </g>
+    </g>
+    <g
+       id="g3948"
+       transform="translate(0,25.995732)"
+       style="stroke:#959595;stroke-opacity:1">
+      <circle
+         cx="24"
+         cy="24"
+         r="17"
+         class="layout"
+         id="circle3950"
+         style="fill:none;stroke:#959595;stroke-width:2.87960957999999989;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+         sodipodi:cx="24"
+         sodipodi:cy="24"
+         sodipodi:rx="17"
+         sodipodi:ry="17"
+         d="M 41,24 C 41,33.388841 33.388841,41 24,41 14.611159,41 7,33.388841 7,24 7,14.611159 14.611159,7 24,7 c 9.388841,0 17,7.611159 17,17 z"
+         transform="matrix(0.52090395,0,0,0.52090395,-0.53190286,-28.457764)"
+         inkscape:export-filename="/home/z4k/www/maps/leaflet-gps/images/g3902.png"
+         inkscape:export-xdpi="99.45063"
+         inkscape:export-ydpi="99.45063" />
+      <g
+         id="g3952"
+         transform="matrix(1.0012467,0,0,1.0012467,0.06626665,-0.22496325)"
+         style="stroke-width:1.45991993000000009;stroke-miterlimit:4;stroke-dasharray:none;stroke:#959595;stroke-opacity:1"
+         inkscape:export-xdpi="99.45063"
+         inkscape:export-ydpi="99.45063">
+        <path
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3954"
+           d="m 1.6430699,-15.711519 4.7285567,0"
+           style="fill:none;stroke:#959595;stroke-width:1.45991993000000009;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+        <path
+           inkscape:transform-center-y="7.8813561"
+           style="fill:none;stroke:#959595;stroke-width:1.45991993000000009;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 11.888704,-5.4658847 0,-4.7285563"
+           id="path3956"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc" />
+        <path
+           inkscape:transform-center-x="-7.881356"
+           sodipodi:nodetypes="cc"
+           inkscape:connector-curvature="0"
+           id="path3958"
+           d="m 22.134338,-15.711519 -4.728556,0"
+           style="fill:none;stroke:#959595;stroke-width:1.45991993000000009;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+        <path
+           inkscape:transform-center-y="-7.881356"
+           style="fill:none;stroke:#959595;stroke-width:1.45991993000000009;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+           d="m 11.888704,-25.957153 0,4.728556"
+           id="path3960"
+           inkscape:connector-curvature="0"
+           sodipodi:nodetypes="cc" />
+      </g>
+    </g>
+  </g>
+</svg>
diff --git a/leaflet-gps/leaflet-gps.css b/leaflet-gps/leaflet-gps.css
new file mode 100644
index 0000000..1f45f47
--- /dev/null
+++ b/leaflet-gps/leaflet-gps.css
@@ -0,0 +1,56 @@
+
+.leaflet-container .leaflet-control-gps {
+	position:relative;
+	float:left;
+	background:#fff;
+	color:#1978cf;
+	-moz-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+	/*background-color: rgba(0, 0, 0, 0.25);*/
+	background-color: rgba(255, 255, 255, 0.8);
+	z-index:1000;	
+	box-shadow: 0 1px 7px rgba(0,0,0,0.65);
+	margin-left:10px;
+	margin-top:10px;
+}
+.leaflet-control-gps .gps-button {
+	display:block;
+	float:left;
+	width:26px;
+	height:26px;
+	background-image: url('gps-icon.png');
+	background-repeat: no-repeat;
+	background-position: 1px 1px;
+	background-color: #fff;
+	border-radius:4px;
+}
+.leaflet-control-gps .gps-button:hover,
+.leaflet-control-gps .gps-button.active:hover {
+	background-color: #f4f4f4;
+}
+.leaflet-control-gps .gps-button.loading,
+.leaflet-control-gps .gps-button.loading:hover {
+	background-position: 1px -28px;
+}
+.leaflet-control-gps .gps-button.disabled {
+	background-position: 1px -28px;
+}
+.leaflet-control-gps .gps-button.active {
+	background-position: 1px -56px;
+}
+
+.leaflet-control-gps .gps-alert {
+	position:absolute;
+	left:26px;
+	bottom:-1px;
+	width:220px;
+	padding:2px;
+	line-height:.95em;
+	color:#e00;
+	border: 1px solid #888;	
+	background-color: rgba(255, 255, 255, 0.75);
+	border-radius:4px;
+}
+
+
diff --git a/leaflet-gps/leaflet-gps.js b/leaflet-gps/leaflet-gps.js
new file mode 100644
index 0000000..9d63537
--- /dev/null
+++ b/leaflet-gps/leaflet-gps.js
@@ -0,0 +1,226 @@
+// MIT by Stefano Cudini <stefano.cudini at gmail.com>
+
+(function (factory) {
+    if(typeof define === 'function' && define.amd) {
+    //AMD
+        define(['leaflet'], factory);
+    } else if(typeof module !== 'undefined') {
+    // Node/CommonJS
+        module.exports = factory(require('leaflet'));
+    } else {
+    // Browser globals
+        if(typeof window.L === 'undefined')
+            throw 'Leaflet must be loaded first';
+        factory(window.L);
+    }
+})(function (L) {
+
+L.Control.Gps = L.Control.extend({
+
+	includes: L.version[0] =='1' ? L.Evented.prototype : L.Mixin.Events,
+	//
+	//Managed Events:
+	//	Event			Data passed			Description
+	//
+	//	gps:located		{marker,latlng}	 	fired after gps marker is located
+	//	gps:disabled	{marker}			fired after gps is disabled
+	//	gps:error	    {message}			fired after gps error
+	//
+	//Methods exposed:
+	//	Method 			Description
+	//
+	//  getLocation		return Latlng and marker of current position
+	//  activate		active tracking on runtime
+	//  deactivate		deactive tracking on runtime
+	//
+	options: {
+		autoActive: false,		//activate control at startup
+		autoCenter: false,		//move map when gps location change
+		maxZoom: null,			//max zoom for autoCenter
+		textErr: '',			//error message on alert notification
+		callErr: null,			//function that run on gps error activating
+		title: 'Center map on your location',
+		marker: null,			//L.Marker used for location, default use a L.CircleMarker
+		style: {				//default L.CircleMarker styles
+			radius: 5,
+			weight: 2,
+			color: '#c20',
+			opacity: 1,
+			fillColor: '#f23',
+			fillOpacity: 1
+		},
+		//accuracy: true,		//show accuracy Circle
+		position: 'topleft',
+		transform: function(latlng) { return latlng },
+		//TODO add gpsLayer
+		//TODO timeout autoCenter
+	},
+
+	initialize: function(options) {
+		if(options && options.style)
+			options.style = L.Util.extend({}, this.options.style, options.style);
+		L.Util.setOptions(this, options);
+		this._errorFunc = this.options.callErr || this.showAlert;
+		this._isActive = false;
+		this._isLoading = false;
+		this._currentLocation = null;	//store last location
+	},
+
+	onAdd: function (map) {
+
+		this._map = map;
+
+		var container = L.DomUtil.create('div', 'leaflet-control-gps');
+
+		this._button = L.DomUtil.create('a', 'gps-button', container);
+		this._button.href = '#';
+		this._button.title = this.options.title;
+
+		L.DomEvent
+			.on(this._button, 'dblclick', L.DomEvent.stop, this)
+			.on(this._button, 'click', L.DomEvent.stop, this)
+			.on(this._button, 'click', this._switchGps, this);
+
+		this._alert = L.DomUtil.create('div', 'gps-alert', container);
+		this._alert.style.display = 'none';
+
+		this._gpsMarker = this.options.marker ? this.options.marker : new L.CircleMarker([0,0], this.options.style);
+		//if(this.options.accuracy)
+		//	this._accuracyCircle = new L.Circle([0,0], this.options.style);
+
+		this._map
+			.on('locationfound', this._drawGps, this)
+			.on('locationerror', this._errorGps, this);
+
+		if(this.options.autoActive)
+			this.activate();
+
+		return container;
+	},
+
+	onRemove: function(map) {
+		this.deactivate();
+
+		map.off('locationfound', this._drawGps, this)
+		   .off('locationerror', this._errorGps, this);
+	},
+
+	_switchGps: function() {
+		if(this._isActive || this._isLoading)
+			this.deactivate();
+		else
+			this.activate();
+	},
+
+	getLocation: function() {	//get last location
+		return this._currentLocation;
+	},
+
+	activate: function() {
+
+		this._isActive = true;
+		this._isLoading = true;
+		this._map.addLayer( this._gpsMarker );
+
+		L.DomUtil.addClass(this._button, 'loading');
+		
+		this._map.once('locationfound', function(e) {
+			
+			L.DomUtil.removeClass(this._button, 'loading');
+			L.DomUtil.removeClass(this._button, 'disabled');
+			L.DomUtil.addClass(this._button, 'active');
+
+			this._isLoading = false;
+			
+			if(this.options.autoCenter)
+				this._map.setView(e.latlng, this.options.maxZoom || this._map.getZoom());
+
+		}, this);
+
+		this._map.locate({
+			enableHighAccuracy: false,
+			watch: true,
+			setView: false,//this.options.autoCenter,
+			//maxZoom: this.options.maxZoom || this._map.getZoom()
+		});
+	},
+
+	deactivate: function() {
+		
+		this._isActive = false;
+		this._isLoading = false;
+		
+		L.DomUtil.removeClass(this._button, 'active');
+		L.DomUtil.removeClass(this._button, 'loading');
+
+		if(this._map) {
+			this._map.stopLocate();
+			this._map.removeLayer( this._gpsMarker );
+		}		
+		
+		//this._gpsMarker.setLatLng([-90,0]);  //move to antarctica!
+		//TODO make method .hide() using _icon.style.display = 'none'
+		this.fire('gps:disabled', {marker: this._gpsMarker});
+	},
+
+	_drawGps: function(e) {
+		//TODO use e.accuracy for gps circle radius/color
+		this._currentLocation = this.options.transform(e.latlng);
+		
+		this._gpsMarker.setLatLng(this._currentLocation);
+
+		if(this.options.autoCenter)
+			this._map.panTo(e.latlng);
+
+	//    	if(this._gpsMarker.accuracyCircle)
+	//    		this._gpsMarker.accuracyCircle.setRadius((e.accuracy / 2).toFixed(0));
+			
+		this.fire('gps:located', {
+			latlng: this._currentLocation,
+			marker: this._gpsMarker
+		});
+	},
+
+	_errorGps: function(e) {
+		this.fire('gps:error', e);
+
+		this.deactivate();
+		
+		L.DomUtil.addClass(this._button, 'disabled');
+
+		this._errorFunc.call(this, this.options.textErr || e.message);
+	},
+
+	/*	_updateAccuracy: function (event) {
+			var newZoom = this._map.getZoom(),
+				scale = this._map.options.crs.scale(newZoom);
+			this._gpsMarker.setRadius(this.options.style.radius * scale);
+			this._gpsMarker.redraw();
+		},
+	*/
+	showAlert: function(text) {
+		this._alert.style.display = 'block';
+		this._alert.innerHTML = text;
+		var that = this;
+		clearTimeout(this.timerAlert);
+		this.timerAlert = setTimeout(function() {
+			that._alert.style.display = 'none';
+		}, 5000);
+	}
+});
+
+L.Map.addInitHook(function () {
+	if (this.options.gpsControl) {
+		this.gpsControl = L.control.gps(this.options.gpsControl);
+		this.addControl(this.gpsControl);
+	}
+});
+
+L.control.gps = function (options) {
+	return new L.Control.Gps(options);
+};
+
+return L.Control.Gps;
+
+});
+


hooks/post-receive
-- 
MirKarte source code repository
(Evolvis project useful-scripts repository mirkarte)


More information about the useful-scripts-commits mailing list