Browse Source

Merge branch 'geo-info'

master
parent
commit
e0bfbf4468
  1. BIN
      img/crosshair.png
  2. 99
      img/geo-info-bbox-center.svg
  3. 99
      img/geo-info-bbox-none.svg
  4. 99
      img/geo-info-bbox-nw.svg
  5. 99
      img/geo-info-bbox-se.svg
  6. 104
      img/geo-info-object-center.svg
  7. 104
      img/geo-info-object-none.svg
  8. 104
      img/geo-info-object-nw.svg
  9. 104
      img/geo-info-object-se.svg
  10. 109
      img/geo-info-object-shape.svg
  11. 2
      index.php
  12. 31
      lang/en.json
  13. 7
      package.json
  14. 58
      src/GeoInfo.css
  15. 241
      src/GeoInfo.js
  16. 26
      src/PluginGeoLocate.js
  17. 24
      src/PluginMeasure.js
  18. 207
      src/formatUnits.js
  19. 17
      src/index.js
  20. 26
      src/options.js

BIN
img/crosshair.png

After

Width: 21  |  Height: 21  |  Size: 235 B

99
img/geo-info-bbox-center.svg

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-bbox-center.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="8.527307"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

99
img/geo-info-bbox-none.svg

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-bbox-none.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="8.527307"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

99
img/geo-info-bbox-nw.svg

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-bbox-nw.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="8.527307"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

99
img/geo-info-bbox-se.svg

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-bbox-se.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="8.527307"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

104
img/geo-info-object-center.svg

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-object-center.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="3.2241055"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:#808080;fill-rule:evenodd;stroke:#808080;stroke-width:0.52916667;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.5"
d="M 0.26458333,295.67707 2.6458333,296.7354 3.96875,293.03123 Z"
id="path5890"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

104
img/geo-info-object-none.svg

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-object-none.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="3.2241055"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:#808080;fill-rule:evenodd;stroke:#808080;stroke-width:0.52916667;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.5"
d="M 0.26458333,295.67707 2.6458333,296.7354 3.96875,293.03123 Z"
id="path5890"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

104
img/geo-info-object-nw.svg

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-object-nw.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="3.2241055"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:#808080;fill-rule:evenodd;stroke:#808080;stroke-width:0.52916667;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.5"
d="M 0.26458333,295.67707 2.6458333,296.7354 3.96875,293.03123 Z"
id="path5890"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

104
img/geo-info-object-se.svg

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-object-se.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="3.2241055"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:#808080;fill-rule:evenodd;stroke:#808080;stroke-width:0.52916667;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.5"
d="M 0.26458333,295.67707 2.6458333,296.7354 3.96875,293.03123 Z"
id="path5890"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

109
img/geo-info-object-shape.svg

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333334"
version="1.1"
id="svg8"
sodipodi:docname="geo-info-object-shape.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="33.1875"
inkscape:cx="3.2241055"
inkscape:cy="8"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1366"
inkscape:window-height="712"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid815" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,296.7354 H 3.96875"
id="path4528"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 3.96875,293.03123 0,3.70417"
id="path4532"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 0,3.70417"
id="path4524"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458333,293.03123 3.70416667,0"
id="path4526"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.52916667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.26458333,294.88332 H 3.96875"
id="path4534"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#a0a0a0;stroke-width:0.5291667;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166667,293.03123 v 3.70417"
id="path4522"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:#808080;fill-rule:evenodd;stroke:#808080;stroke-width:0.52916667;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;opacity:0.5"
d="M 0.26458333,295.67707 2.6458333,296.7354 3.96875,293.03123 Z"
id="path5890"
inkscape:connector-curvature="0" />
<path
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.52916676;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0.26458336,295.67707 2.38125004,1.05833 1.3229167,-3.70417 z"
id="path5890-7"
inkscape:connector-curvature="0" />
</g>
</svg>

2
index.php

@ -45,7 +45,7 @@ html_export_var(array(
<link rel="stylesheet" href="node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.css" />
<link rel="stylesheet" href="node_modules/leaflet.polylinemeasure/Leaflet.PolylineMeasure.css" />
<script src="node_modules/leaflet/dist/leaflet.js"></script>
<script src="node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.js"></script>
<script src="node_modules/leaflet.locatecontrol/src/L.Control.Locate.js"></script>
<script src="node_modules/leaflet-textpath/leaflet.textpath.js"></script>
<script src="node_modules/leaflet-polylineoffset/leaflet.polylineoffset.js"></script>
<script src="node_modules/leaflet.polylinemeasure/Leaflet.PolylineMeasure.js"></script>

31
lang/en.json

@ -18,10 +18,41 @@
"facilities": "Facilities",
"filter:title": "Title",
"filter:type": "Type",
"formatUnits:coordFormat": "Coordinate format",
"formatUnits:coordSpacer": "Coordinate spacer",
"formatUnits:system": "Unit system",
"formatUnits:system:si": "SI Units",
"formatUnits:system:imp": "Imperial units",
"formatUnits:system:nautical": "Nautical",
"formatUnits:system:m": "Always meter",
"formatUnits:speed": "Speed unit",
"formatUnits:speed:ft/s": "ft/s",
"formatUnits:speed:km/h": "km/h",
"formatUnits:speed:kn": "kn",
"formatUnits:speed:m/s": "m/s",
"formatUnits:speed:mi/h": "mph",
"form_element:please_select": "-- please select --",
"geoinfo:nw-corner": "Northwestern corner",
"geoinfo:center": "Center",
"geoinfo:centroid": "Centroid",
"geoinfo:se-corner": "Southeastern corner",
"geoinfo:mouse": "Mouse position",
"geoinfo:location": "Current location",
"geoinfo:zoom": "Zoom level",
"geoinfo:header": "Geometry",
"geoinfo:length": "Length",
"geoinfo:area": "Area",
"header:attributes": "Attributes",
"header:export": "Export",
"header:osm_meta": "OSM Meta",
"heading:N": "N",
"heading:NE": "NE",
"heading:E": "E",
"heading:SE": "SE",
"heading:S": "S",
"heading:SW": "SW",
"heading:W": "W",
"heading:NW": "NW",
"images": "Images",
"invalid value": "invalid value",
"loading": "Loading ...",

7
package.json

@ -12,13 +12,15 @@
"@babel/preset-env": "^7.7.7",
"@fortawesome/fontawesome-free": "^5.12.0",
"@mapbox/maki": "^5.0.0",
"@turf/area": "^6.0.1",
"@turf/length": "^6.0.2",
"async": "^2.5.0",
"async-foreach": "^0.1.3",
"babelify": "^10.0.0",
"color-interpolate": "^1.0.5",
"event-emitter": "^0.3.5",
"file-saver": "^2.0.0",
"font-awesome": "^4.7.0",
"formatcoords": "^1.1.3",
"i18next-client": "^1.11.4",
"ip-location": "^1.0.1",
"json-multiline-strings": "^0.1.0",
@ -26,9 +28,10 @@
"leaflet-geosearch": "^2.4.0",
"leaflet-polylineoffset": "^1.1.0",
"leaflet-textpath": "git+https://github.com/makinacorpus/Leaflet.TextPath.git#leaflet0.8-dev",
"leaflet.locatecontrol": "^0.61.0",
"leaflet.locatecontrol": "git+https://github.com/plepe/leaflet-locatecontrol.git#initialZoomLevel",
"leaflet.polylinemeasure": "git+https://github.com/ppete2/Leaflet.PolylineMeasure.git",
"md5": "^2.2.1",
"measure-ts": "^3.3.2",
"modulekit-tabs": "^0.2.2",
"moment": "^2.18.1",
"natsort": "^1.0.6",

58
src/GeoInfo.css

@ -0,0 +1,58 @@
.geo-info > div {
display: flex;
position: relative;
align-items: end;
margin-top: 0.5em;
}
.geo-info > div:first-of-type {
margin-top: 0;
}
.geo-info > div.empty {
margin-top: 0;
display: none;
}
.geo-info > div::before {
width: 16px;
height: 16px;
content: ' ';
margin-right: 0.5em;
}
.geo-info > .bbox-nw-corner::before {
background: url("../img/geo-info-bbox-nw.svg");
}
.geo-info > .bbox-center::before {
background: url("../img/geo-info-bbox-center.svg");
}
.geo-info > .bbox-se-corner::before {
background: url("../img/geo-info-bbox-se.svg");
}
.geo-info > .object-shape::before {
background: url("../img/geo-info-object-shape.svg");
}
.geo-info > .object-nw-corner::before {
background: url("../img/geo-info-object-nw.svg");
}
.geo-info > .object-center::before {
background: url("../img/geo-info-object-center.svg");
}
.geo-info > .object-se-corner::before {
background: url("../img/geo-info-object-se.svg");
}
.geo-info > .zoom::before,
.geo-info > .location::before,
.geo-info > .mouse::before {
font-family: "Font Awesome 5 Free";
font-weight: 900;
font-size: 1.25em;
text-align: center;
}
.geo-info > .zoom::before {
content: "\f689";
}
.geo-info > .location::before {
content: "\f3c5";
}
.geo-info > .mouse::before {
content: "\f245";
}

241
src/GeoInfo.js

@ -0,0 +1,241 @@
const turf = {
area: require('@turf/area').default,
length: require('@turf/length').default
}
const tabs = require('modulekit-tabs')
const formatUnits = require('./formatUnits')
require('./GeoInfo.css')
function heading (value) {
return [ 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'N' ][Math.round(value / 45)]
}
register_hook('init', function () {
let tab = new tabs.Tab({
id: 'search',
weight: -1
})
tab.content.classList.add('geo-info')
global.tabs.add(tab)
updateTabHeader(tab.header)
tab.header.title = lang('geoinfo:header')
let crosshairIcon = L.icon({
iconUrl: 'img/crosshair.png',
iconSize: [21, 21],
iconAnchor: [10, 10],
})
let crosshair = new L.marker([0,0], {
icon: crosshairIcon,
clickable:false,
pane: "crosshair800"
})
global.map.createPane('crosshair800')
global.map.getPane('crosshair800').style.zIndex = 800
global.map.getPane('crosshair800').style.pointerEvents = 'none'
let domZoom = document.createElement('div')
domZoom.className = 'zoom'
domZoom.title = lang('geoinfo:zoom')
tab.content.appendChild(domZoom)
let domBBoxNW = document.createElement('div')
domBBoxNW.className = 'bbox-nw-corner'
domBBoxNW.title = lang('geoinfo:nw-corner')
tab.content.appendChild(domBBoxNW)
let domCenter = document.createElement('div')
domCenter.className = 'bbox-center'
domCenter.title = lang('geoinfo:center')
tab.content.appendChild(domCenter)
let domBBoxSE = document.createElement('div')
domBBoxSE.className = 'bbox-se-corner'
domBBoxSE.title = lang('geoinfo:se-corner')
tab.content.appendChild(domBBoxSE)
let domMouse = document.createElement('div')
domMouse.className = 'mouse empty'
domMouse.title = lang('geoinfo:mouse')
tab.content.appendChild(domMouse)
let domLocation = document.createElement('div')
domLocation.title = lang('geoinfo:location')
domLocation.className = 'location empty'
tab.content.appendChild(domLocation)
function getPrecision () {
let zoom = global.map.getZoom()
return zoom > 16 ? 5
: zoom > 8 ? 4
: zoom > 4 ? 3
: zoom > 2 ? 2
: zoom > 1 ? 1
: 0
}
function updateMapView () {
crosshair.setLatLng(global.map.getCenter())
let scale = formatUnits.distance(global.map.getMetersPerPixel())
let scale2 = formatUnits.area(Math.pow(global.map.getMetersPerPixel(), 2))
let precision = getPrecision()
domZoom.innerHTML = '<span class="value">z' +
Math.round(global.map.getZoom()) + ', ' +
scale + '/px, ' +
scale2 + '/px²' +
'</span>'
let bounds = map.getBounds()
domBBoxNW.innerHTML = '<span class="value">' + formatUnits.coord(bounds.getNorthWest().wrap(), { precision }) + '</span>'
domCenter.innerHTML = '<span class="value">' + formatUnits.coord(bounds.getCenter().wrap(), { precision }) + '</span>'
domBBoxSE.innerHTML = '<span class="value">' + formatUnits.coord(bounds.getSouthEast().wrap(), { precision }) + '</span>'
}
let lastMouseEvent
function updateMouse (e) {
if (!e) {
e = lastMouseEvent
}
if (e) {
let precision = getPrecision()
domMouse.innerHTML = '<span class="value">' + formatUnits.coord(e.latlng.wrap(), { precision }) + '</span>'
domMouse.classList.remove('empty')
} else {
removeMouse()
}
lastMouseEvent = e
}
function removeMouse () {
lastMouseEvent = null
domMouse.innerHTML = ''
domMouse.classList.add('empty')
}
let lastLocation
function updateLocation (e) {
if (e) {
lastLocation = e
} else {
e = lastLocation
}
if (e) {
domLocation.innerHTML = '<span class="value">' + formatUnits.coord(e.latlng.wrap(), { precision: 5 }) +
(typeof e.accuracy !== 'undefined' ? (global.options.formatUnitsCoordSpacer || ', ') + '± ' + formatUnits.distance(e.accuracy.toFixed(0)) : '') + '<br/>' +
(typeof e.altitude !== 'undefined' ? '<i class="fas fa-mountain"></i> ' + formatUnits.height(e.altitude) + (typeof e.altitudeAccuracy !== 'undefined' ? ' ± ' + formatUnits.distance(e.altitudeAccuracy) : '') + ' ' : '') +
(typeof e.speed !== 'undefined' ? '<i class="fas fa-tachometer-alt"></i> ' + formatUnits.speed(e.speed) + ' ' : '') +
(typeof e.heading !== 'undefined' ? '<i class="fas fa-compass"></i> ' + lang('heading:' + heading(e.heading)) + ' (' + e.heading.toFixed(0) + '°)' : '') +
'</span>'
domLocation.classList.remove('empty')
}
}
function saveLocation (e) {
lastLocation = e
}
global.map.on('move', () => {
updateTabHeader(tab.header)
})
global.map.on('locationfound', saveLocation)
tab.on('select', () => {
crosshair.addTo(global.map)
updateMapView()
updateLocation()
global.map.on('move', updateMapView)
global.map.on('mousemove', updateMouse)
global.map.on('mouseout', removeMouse)
global.map.off('locationfound', saveLocation)
global.map.on('locationfound', updateLocation)
})
tab.on('unselect', () => {
crosshair.removeFrom(global.map)
global.map.off('move', updateMapView)
global.map.off('mousemove', updateMouse)
global.map.off('mouseout', removeMouse)
global.map.off('locationfound', updateLocation)
global.map.on('locationfound', saveLocation)
})
register_hook('format-units-refresh', updateMapView)
register_hook('format-units-refresh', updateMouse)
register_hook('format-units-refresh', removeMouse)
register_hook('format-units-refresh', updateLocation)
})
let showDetailsCurrent
register_hook('show-details', (data, category, dom, callback) => {
let div = document.createElement('div')
dom.appendChild(div)
showDetailsCurrent = [ data, category, div ]
geoInfoShowDetails.apply(this, showDetailsCurrent)
callback()
})
register_hook('format-units-refresh', () => {
if (showDetailsCurrent) {
showDetailsCurrent[2].innerHTML = ''
geoInfoShowDetails.apply(this, showDetailsCurrent)
}
})
function geoInfoShowDetails (data, category, div) {
let ob = data.object
let result = '<div class="geo-info"><h3>' + lang('geoinfo:header') + '</h3>'
let geojson = ob.GeoJSON()
let area = turf.area(geojson)
let length = turf.length(geojson) * 1000
if (area !== 0 || length !== 0) {
result += '<div class="object-shape">' +
'<span class="value">' +
lang('geoinfo:length') + ': ' + formatUnits.distance(length) +
(area === 0 ? '' : ', ' + lang('geoinfo:area') + ': ' + formatUnits.area(area)) +
'</span></div>'
}
if (ob.bounds.minlat !== ob.bounds.maxlat || ob.bounds.minlon !== ob.bounds.maxlon) {
result += '<div class="object-nw-corner" title="' + lang('geoinfo:nw-corner') + '"><span class="value">' + formatUnits.coord({ lat: ob.bounds.minlat, lng: ob.bounds.maxlon }) + '</span></div>'
}
result += '<div class="object-center" title="' + lang('geoinfo:centroid') + '"><span class="value">' + formatUnits.coord({ lat: ob.center.lat, lng: ob.center.lon }) + '</span></div>'
if (ob.bounds.minlat !== ob.bounds.maxlat || ob.bounds.minlon !== ob.bounds.maxlon) {
result += '<div class="object-se-corner" title="' + lang('geoinfo:se-corner') + '"><span class="value">' + formatUnits.coord({ lat: ob.bounds.maxlat, lng: ob.bounds.minlon }) + '</span></div>'
}
result += '</div>'
div.innerHTML = result
}
function updateTabHeader (header) {
if (!global.map._loaded) {
return
}
let center = global.map.getCenter().wrap()
if (center.lng < -35) {
header.innerHTML = '<i class="fas fa-globe-americas"></i>'
} else if (center.lng > 80) {
header.innerHTML = '<i class="fas fa-globe-asia"></i>'
} else if (center.lat < 30) {
header.innerHTML = '<i class="fas fa-globe-africa"></i>'
} else {
header.innerHTML = '<i class="fas fa-globe-europe"></i>'
}
}

26
src/PluginGeoLocate.js

@ -0,0 +1,26 @@
register_hook('init', function () {
// Geo location
L.control.locate({
locateOptions: {
enableHighAccuracy: true
},
flyTo: true,
keepCurrentZoomLevel: true,
initialZoomLevel: 17,
drawCircle: true,
circleStyle: {
weight: 0,
fillColor: '#ff0000'
},
markerStyle: {
color: '#ff0000',
fillColor: '#ff0000'
},
compassStyle: {
color: '#ff0000',
fillColor: '#ff0000'
},
showCompass: true,
showPopup: false
}).addTo(map)
})

24
src/PluginMeasure.js

@ -0,0 +1,24 @@
const formatUnits = require('./formatUnits')
let control
let unitSystems = {
si: 'metres',
imp: 'landmiles',
nautical: 'nauticalmiles',
m: 'metres'
}
register_hook('init', function () {
// Measurement plugin
if (L.control.polylineMeasure) {
control = L.control.polylineMeasure({
unit: unitSystems[formatUnits.settings.system]
}).addTo(map)
}
})
register_hook('format-units-refresh', () => {
if (control) {
control.options.unit = unitSystems[formatUnits.settings.system]
}
})

207
src/formatUnits.js

@ -0,0 +1,207 @@
var OverpassLayer = require('overpass-layer')
const { measureFrom } = require('measure-ts')
const formatcoords = require('formatcoords')
const settings = {
coordFormat: 'FFf',
coordSpacer: ', ',
system: 'si',
speed: 'km/h'
}
const distanceUnits = {
si: ['cm', 'm', 'km'],
imp: ['in', 'ft', 'yd', 'mi'],
nautical: ['M'],
m: ['m']
}
const areaUnits = {
si: ['cm2', 'm2', 'ha', 'km2'],
imp: ['in2', 'ft2', 'yd2', 'ac', 'mi2'],
nautical: ['M2'],
m: ['m2']
}
const coordsPrecisionFormats = {
'FFf': [
'DD X',
'DD MM X',
'DD MM X',
'DD MM ss0 X',
'DD MM ss1 X',
'DD MM ss2 X',
'DD MM ss3 X'
],
'Ff': [
'DD X',
'DD MM X',
'DD MM X',
'DD mm1 X',
'DD mm2 X',
'DD mm3 X',
'DD mm4 X'
],
'f': [
'DD X',
'dd1 X',
'dd2 X',
'dd3 X',
'dd4 X',
'dd5 X',
'dd6 X'
]
}
module.exports = {
distance: value => {
const measure = measureFrom.apply(this, distanceUnits[settings.system])
return measure(value).toString()
},
height: value => {
switch (settings.system) {
case 'imp':
return (value / 0.3048) .toFixed(0) + ' ft'
case 'nautical':
// not defined for nautical, use 'm' instead
case 'si':
case 'm':
default:
return value.toFixed(0) + ' m'
}
const measure = measureFrom.apply(this, distanceUnits[settings.system])
return measure(value).toString()
},
area: value => {
const measure = measureFrom.apply(this, areaUnits[settings.system])
return measure(value).toString()
},
speed: value => {
switch (settings.speed) {
case 'm/s':
return value.toFixed(0) + ' ' + lang('formatUnits:speed:m/s')
case 'km/h':
return (value * 3.6).toFixed(0) + ' ' + lang('formatUnits:speed:km/h')
case 'mi/h':
return (value * 2.236936).toFixed(0) + ' ' + lang('formatUnits:speed:mi/h')
case 'kn':
return (value * 1.943844).toFixed(0) + ' ' + lang('formatUnits:speed:kn')
case 'ft/s':
return (value * 3.280840).toFixed(0) + ' ' + lang('formatUnits:speed:ft/s')
}
},
coord: (value, options = {}) => {
let format = settings.coordFormat
options.precision = 'precision' in options ? options.precision : 5
let decimalPlaces = 'decimalPlaces' in options ? options.decimalPlaces : options.precision
if ('precision' in options && settings.coordFormat in coordsPrecisionFormats) {
if (options.precision > coordsPrecisionFormats[settings.coordFormat].length) {
format = coordsPrecisionFormats[settings.coordFormat][coordsPrecisionFormats[settings.coordFormat].length - 1]
} else {
format = coordsPrecisionFormats[settings.coordFormat][options.precision]
}
}
let m = format.match(/^(.*)(s|m|d)([0-9]+)(.*)$/)
if (m) {
format = m[1] + m[2] + m[4]
decimalPlaces = parseInt(m[3])
}
return formatcoords(value).format(format, {
latLonSeparator: settings.coordSpacer,
decimalPlaces
})
},
settings
}
register_hook('options_form', def => {
def.formatUnitsSystem = {
'name': lang('formatUnits:system'),
'type': 'select',
'values': {
'si': lang('formatUnits:system:si'),
'imp': lang('formatUnits:system:imp'),
'nautical': lang('formatUnits:system:nautical'),
'm': lang('formatUnits:system:m'),
},
'default': settings.system
}
def.formatUnitsCoordFormat = {
'name': lang('formatUnits:coordFormat'),
'desc': 'A format definition as specified in <a target="_blank" href="https://github.com/nerik/formatcoords">module formatCoords</a>',
'type': 'select_other',
'values': {
'FFf': 'DD° MM′ SS.SSS″ X',
'Ff': 'DD° MM.MMM′ X',
'f': 'DD.DDD° X',
'd': '±DD.DDD'
},
'default': settings.coordFormat
}
def.formatUnitsCoordSpacer = {
'name': lang('formatUnits:coordSpacer'),
'type': 'select_other',
'values': {
' ': 'Space',
', ': 'Colon'
},
'default': settings.coordSpacer
}
def.formatUnitsSpeed = {
'name': lang('formatUnits:speed'),
'type': 'select',
'values': {
'km/h': lang('formatUnits:speed:km/h'),
'mi/h': lang('formatUnits:speed:mi/h'),
'm/s': lang('formatUnits:speed:m/s'),
'kn': lang('formatUnits:speed:kn'),
'ft/s': lang('formatUnits:speed:ft/s')
},
'default': settings.speed
}
})
register_hook('options_orig_data', data => {
data.formatUnitsSystem = settings.system
data.formatUnitsCoordFormat = settings.coordFormat
data.formatUnitsCoordSpacer = settings.coordSpacer
data.formatUnitsSpeed = settings.speed
})
register_hook('options_save', data => {
let old = JSON.stringify(settings)
settings.coordFormat = data.formatUnitsCoordFormat
settings.coordSpacer = data.formatUnitsCoordSpacer
settings.system = data.formatUnitsSystem
settings.speed = data.formatUnitsSpeed
if (old !== JSON.stringify(settings)) {
call_hooks('format-units-refresh')
}
})
register_hook('init', () => {
let old = JSON.stringify(settings)
settings.coordFormat = global.options.formatUnitsCoordFormat || settings.coordFormat
settings.coordSpacer = global.options.formatUnitsCoordSpacer || settings.coordSpacer
settings.system = global.options.formatUnitsSystem || settings.system
settings.speed = global.options.formatUnitsSpeed || settings.speed
if (old !== JSON.stringify(settings)) {
call_hooks('format-units-refresh')
}
})
OverpassLayer.twig.extendFunction('formatDistance', function () {
return module.exports.distance.call(this, arguments[0])
})

17
src/index.js

@ -38,6 +38,9 @@ require('./permalink')
//require('./leaflet-geo-search')
require('./nominatim-search')
require('./CategoryOverpassFilter')
require('./GeoInfo')
require('./PluginMeasure')
require('./PluginGeoLocate')
let exportAll = require('./exportAll')
window.onload = function () {
@ -65,20 +68,6 @@ window.onload = function () {
}
function onload2 (initState) {
// Measurement plugin
if (L.control.polylineMeasure) {
L.control.polylineMeasure({
}).addTo(map)
}
// Geo location
L.control.locate({
keepCurrentZoomLevel: true,
drawCircle: false,
drawMarker: false,
showPopup: false
}).addTo(map)
// Scale bar
L.control.scale().addTo(map)

26
src/options.js

@ -1,6 +1,7 @@
/* globals form, ajax, options:true */
var moduleOptions = {}
var prevPage
var optionsFormEl
register_hook('init', function () {
var menu = document.getElementById('menu')
@ -34,23 +35,34 @@ moduleOptions.open = function () {
var dom = document.getElementById('contentOptions')
dom.innerHTML = ''
let orig_options = {
debug: false
}
call_hooks('options_orig_data', orig_options)
for (let k in orig_options) {
if (!(k in options)) {
options[k] = orig_options[k]
}
}
optionsForm.set_data(options)
var f = document.createElement('form')
f.onsubmit = moduleOptions.submit.bind(this, optionsForm)
dom.appendChild(f)
optionsFormEl = document.createElement('form')
optionsFormEl.onsubmit = moduleOptions.submit.bind(this, optionsForm)
dom.appendChild(optionsFormEl)
optionsForm.show(f)
optionsForm.show(optionsFormEl)
var input = document.createElement('button')
input.innerHTML = lang('save')
f.appendChild(input)
optionsFormEl.appendChild(input)
input = document.createElement('button')
input.innerHTML = lang('cancel')
f.appendChild(input)
optionsFormEl.appendChild(input)
input.onclick = function () {
document.getElementById('content').className = prevPage
dom.removeChild(optionsFormEl)
return false
}
@ -71,6 +83,8 @@ moduleOptions.submit = function (optionsForm) {
let oldOptions = options
options = data
optionsFormEl.parentNode.removeChild(optionsFormEl)
document.getElementById('content').className = prevPage
call_hooks('options_save', data, oldOptions)

Loading…
Cancel
Save