leaflet-map.init.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /******/ (function() { // webpackBootstrap
  2. var __webpack_exports__ = {};
  3. /*!************************************************!*\
  4. !*** ./resources/js/pages/leaflet-map.init.js ***!
  5. \************************************************/
  6. /*
  7. Template Name: Skote - Admin & Dashboard Template
  8. Author: Themesbrand
  9. Website: https://themesbrand.com/
  10. Contact: themesbrand@gmail.com
  11. File: leaflet init js
  12. */
  13. // leaflet-map
  14. var mymap = L.map('leaflet-map').setView([51.505, -0.09], 13);
  15. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  16. maxZoom: 18,
  17. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  18. id: 'mapbox/streets-v11',
  19. tileSize: 512,
  20. zoomOffset: -1
  21. }).addTo(mymap); // leaflet-map-marker
  22. var markermap = L.map('leaflet-map-marker').setView([51.505, -0.09], 13);
  23. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  24. maxZoom: 18,
  25. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  26. id: 'mapbox/streets-v11',
  27. tileSize: 512,
  28. zoomOffset: -1
  29. }).addTo(markermap);
  30. L.marker([51.5, -0.09]).addTo(markermap);
  31. L.circle([51.508, -0.11], {
  32. color: '#34c38f',
  33. fillColor: '#34c38f',
  34. fillOpacity: 0.5,
  35. radius: 500
  36. }).addTo(markermap);
  37. L.polygon([[51.509, -0.08], [51.503, -0.06], [51.51, -0.047]], {
  38. color: '#556ee6',
  39. fillColor: '#556ee6'
  40. }).addTo(markermap); // Working with popups
  41. var popupmap = L.map('leaflet-map-popup').setView([51.505, -0.09], 13);
  42. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  43. maxZoom: 18,
  44. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  45. id: 'mapbox/streets-v11',
  46. tileSize: 512,
  47. zoomOffset: -1
  48. }).addTo(popupmap);
  49. L.marker([51.5, -0.09]).addTo(popupmap).bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
  50. L.circle([51.508, -0.11], 500, {
  51. color: '#f46a6a',
  52. fillColor: '#f46a6a',
  53. fillOpacity: 0.5
  54. }).addTo(popupmap).bindPopup("I am a circle.");
  55. L.polygon([[51.509, -0.08], [51.503, -0.06], [51.51, -0.047]], {
  56. color: '#556ee6',
  57. fillColor: '#556ee6'
  58. }).addTo(popupmap).bindPopup("I am a polygon.");
  59. var popup = L.popup(); // leaflet-map-custom-icons
  60. var customiconsmap = L.map('leaflet-map-custom-icons').setView([51.5, -0.09], 13);
  61. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  62. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  63. }).addTo(customiconsmap);
  64. var LeafIcon = L.Icon.extend({
  65. options: {
  66. iconSize: [45, 95],
  67. iconAnchor: [22, 94],
  68. popupAnchor: [-3, -76]
  69. }
  70. });
  71. var greenIcon = new LeafIcon({
  72. iconUrl: 'assets/images/logo.svg'
  73. });
  74. L.marker([51.5, -0.09], {
  75. icon: greenIcon
  76. }).addTo(customiconsmap); // Interactive Choropleth Map
  77. var interactivemap = L.map('leaflet-map-interactive-map').setView([37.8, -96], 4);
  78. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  79. maxZoom: 18,
  80. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  81. id: 'mapbox/light-v9',
  82. tileSize: 512,
  83. zoomOffset: -1
  84. }).addTo(interactivemap); // get color depending on population density value
  85. function getColor(d) {
  86. return d > 1000 ? '#435fe3' : d > 500 ? '#556ee6' : d > 200 ? '#677de9' : d > 100 ? '#798ceb' : d > 50 ? '#8a9cee' : d > 20 ? '#9cabf0' : d > 10 ? '#aebaf3' : '#c0c9f6';
  87. }
  88. function style(feature) {
  89. return {
  90. weight: 2,
  91. opacity: 1,
  92. color: 'white',
  93. dashArray: '3',
  94. fillOpacity: 0.7,
  95. fillColor: getColor(feature.properties.density)
  96. };
  97. }
  98. var geojson = L.geoJson(statesData, {
  99. style: style
  100. }).addTo(interactivemap); // leaflet-map-group-control
  101. var cities = L.layerGroup();
  102. L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities), L.marker([39.74, -104.99]).bindPopup('This is Denver, CO.').addTo(cities), L.marker([39.73, -104.8]).bindPopup('This is Aurora, CO.').addTo(cities), L.marker([39.77, -105.23]).bindPopup('This is Golden, CO.').addTo(cities);
  103. var mbAttr = 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  104. mbUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
  105. var grayscale = L.tileLayer(mbUrl, {
  106. id: 'mapbox/light-v9',
  107. tileSize: 512,
  108. zoomOffset: -1,
  109. attribution: mbAttr
  110. }),
  111. streets = L.tileLayer(mbUrl, {
  112. id: 'mapbox/streets-v11',
  113. tileSize: 512,
  114. zoomOffset: -1,
  115. attribution: mbAttr
  116. });
  117. var layergroupcontrolmap = L.map('leaflet-map-group-control', {
  118. center: [39.73, -104.99],
  119. zoom: 10,
  120. layers: [streets, cities]
  121. });
  122. var baseLayers = {
  123. "Grayscale": grayscale,
  124. "Streets": streets
  125. };
  126. var overlays = {
  127. "Cities": cities
  128. };
  129. L.control.layers(baseLayers, overlays).addTo(layergroupcontrolmap);
  130. /******/ })()
  131. ;