index.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!doctype HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>leaflet-measure</title>
  6. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
  7. <link rel="stylesheet" href="leaflet-measure.css">
  8. <style>
  9. body {
  10. font-size: 14px;
  11. font-family: Helvetica, sans-serif;
  12. font-weight: 400;
  13. line-height: 1;
  14. color: #222;
  15. text-rendering: optimizeLegibility;
  16. -webkit-font-smoothing: antialiased;
  17. }
  18. body {
  19. margin: 0 20px 20px;
  20. }
  21. h1, h2 {
  22. margin: 20px 0 0;
  23. font-size: 1.4em;
  24. font-weight: normal;
  25. line-height: 1;
  26. }
  27. h1 {
  28. display: inline-block;
  29. font-size: 1.4em;
  30. }
  31. h2 {
  32. font-size: 1.1em;
  33. }
  34. pre {
  35. line-height: 1.5em;
  36. }
  37. p.github {
  38. display: inline-block;
  39. margin: 20px 0 0 20px;
  40. font-size: 1.2em;
  41. }
  42. a, a:visited, a:hover, a:active, a:focus {
  43. text-decoration: none;
  44. }
  45. #map {
  46. height: 500px;
  47. margin: 20px 20px 0 0;
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <h1>leaflet-measure</h1>
  53. <p class="github"><a href="//github.com/ljagis/leaflet-measure">github.com/ljagis/leaflet-measure</a></p>
  54. <div id="map"></div>
  55. <h2><code>measurefinish</code> event data:</h2>
  56. <pre id="eventoutput">...</pre>
  57. <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
  58. <script src="leaflet-measure.js"></script>
  59. <script>
  60. (function(L, document) {
  61. var map = L.map('map', {
  62. center: [29.749817, -95.080757],
  63. zoom: 16,
  64. measureControl: true
  65. });
  66. L.tileLayer('//server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  67. minZoom: 14,
  68. maxZoom: 18,
  69. attribution: '&copy; Esri &mdash; Sources: Esri, DigitalGlobe, Earthstar Geographics, CNES/Airbus DS, GeoEye, USDA FSA, USGS, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community'
  70. }).addTo(map);
  71. map.on('measurefinish', function(evt) {
  72. writeResults(evt);
  73. });
  74. function writeResults(results) {
  75. document.getElementById('eventoutput').innerHTML = JSON.stringify(
  76. {
  77. area: results.area,
  78. areaDisplay: results.areaDisplay,
  79. lastCoord: results.lastCoord,
  80. length: results.length,
  81. lengthDisplay: results.lengthDisplay,
  82. pointCount: results.pointCount,
  83. points: results.points
  84. },
  85. null,
  86. 2
  87. );
  88. }
  89. })(window.L, window.document);
  90. </script>
  91. </body>
  92. </html>