Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Population Density</title>
  5. <meta charset="utf-8" />
  6. <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
  7. <link rel="stylesheet" href="leaflet.css" />
  8. <link rel="stylesheet" href="POPCEN/Popcen.css" />
  9. <script src="leaflet.js"></script>
  10. <script src="leaflet-google.js"></script>
  11. <script src="leaflet.groupedlayercontrol.js"></script>
  12. <script src="COMMON/nepalar.js"></script>
  13. <script src="ADMINISTRATIVE/vdcar.js"></script>
  14.  
  15. </head>
  16. <body>
  17. <div id="map" style="position: absolute; top: 5; bottom: 5; left: 5;
  18. right: 5; z-index: 9999; width: 99%; height: 98%">
  19. </div>
  20. <script>
  21. var map = L.map('map', {zoomControl: false, maxZoom: 12}).setView([28.1,84.1], 7);
  22. new L.Control.Zoom({ position: 'bottomright' }).addTo(map);
  23. var noneAttrib='Nepal Map &copy <a href="http://www.dos.gov.np/" target="_blank">Survey Department</a>, Census Data &copy <a href="http://www.cbs.gov.np/" target="_blank">CBS</a>, Nepal';
  24. var none = new L.tileLayer('', {attribution: noneAttrib});
  25. var googleAttrib='Reference Map Data &copy; <a href="http://google.org">GoogleRoadMap</a>';
  26. none.addTo(map);
  27.  
  28. var infonep = L.control({position: 'bottomleft'});
  29. infonep.onAdd = function (map) {
  30. this._div = L.DomUtil.create('div', 'infonep'); // create a div with a class "infonep"
  31. this.update();
  32. return this._div;
  33. };
  34.  
  35. infonep.update = function (props) {
  36. this._div.innerHTML = '<h4>Nepal Population Information:</h4>' + '<hr>' + (props ?
  37. '<b>' + 'NEPAL' + '</b>'
  38. + '<br/>' + 'Population: ' + props.POP68 + '</b>'
  39. + '<br/>' + 'Male Population: ' + props.MALE68 + '</b>'
  40. + '<br/>' + 'Female Population: ' + props.FEMALE68 + '</b>'
  41. + '<br/>' + 'Area (Sq. Km.): ' + props.AREA_SQKM + '</b>'
  42. + '<br/>' + '<b>' + 'Population Density: ' + props.POPDEN68 + ' people / Sq.Km.<sup>2</sup>' + '</b>'
  43. : 'Move mouse over the country');
  44. };
  45. infonep.addTo(map);
  46. function getColor(d) {
  47. return d > 1000 ? '#662506' :
  48. d > 800 ? '#993404' :
  49. d > 600 ? '#CC4C02' :
  50. d > 400 ? '#EC7014' :
  51. d > 200 ? '#FE9929' :
  52. d > 100 ? '#FEC44F' :
  53. d > 50 ? '#FEE391' :
  54. '#FFFFE5';
  55. }
  56.  
  57. function stylenep(feature) {
  58. return {
  59. fillColor: getColor(feature.properties.POPDEN68),
  60. weight: 1,
  61. opacity: 1,
  62. color: 'white',
  63. dashArray: '2',
  64. fillOpacity: 0.7
  65. };
  66. }
  67.  
  68. var popNep = new L.geoJson(nepalar, {
  69. style: stylenep,
  70. onEachFeature: function (feature, layer) {
  71. var defaultStyle = layer.style,
  72. that = this;//NEW
  73. layer.on('mouseover', function (e) {
  74. this.setStyle({
  75. weight: 3,
  76. color: '#666',
  77. dashArray: '',
  78. fillOpacity: 0.7
  79. });
  80. infonep.update(layer.feature.properties);
  81. });
  82. layer.on('mouseout', function (e) {
  83. popNep.resetStyle(e.target); //NEW
  84. infonep.update();
  85. });
  86. }
  87. });
  88. map.addLayer(popNep);
  89.  
  90. function stylevdc(feature) {
  91. return {
  92. fillColor: 'transparent',
  93. weight: 0.1,
  94. opacity: 1,
  95. color: '#000000',
  96. fillOpacity: 0.7
  97. };
  98. }
  99.  
  100. var popVdc = L.geoJson(vdcar, {
  101. style: stylevdc,
  102. onEachFeature: function (feature, layer) {
  103. layer.bindPopup("Zone: " + feature.properties.ZNAME
  104. + '<br>' + "District: " + feature.properties.DNAME
  105. + '<br>' + "VDC: " + feature.properties.GAZETTE);
  106. }
  107. });
  108.  
  109. var googleLayer = new L.Google('ROADMAP', {attribution: googleAttrib + ' ' + noneAttrib});
  110. var none = new L.tileLayer('', {attribution: noneAttrib});
  111. var baseMaps = {
  112. "Google Base Map": googleLayer,
  113. "Turn Off Base Map": none,
  114. };
  115.  
  116. var groupedOverlays = {
  117. "AdminDivisions": {
  118. "Nepal Population": popNep,
  119. "VDCs(Click to display name)": popVdc
  120. }
  121. };
  122.  
  123. L.control.groupedLayers(baseMaps, groupedOverlays, {collapsed: false}).addTo(map);
  124.  
  125. map.on ('overlayadd', function (eventLayer) {
  126. if (eventLayer.name === 'Nepal Population') {
  127. infonep.addTo(map);
  128. } else if (eventLayer.name === 'VDCs(Click to display name)') {
  129. map.addLayer(popVdc);
  130. } else {
  131. }
  132. });
  133. map.on ('overlayremove', function (eventLayer) {
  134. if (eventLayer.name === 'Nepal Population') {
  135. map.removeControl(infonep);
  136. } else if (eventLayer.name === 'VDCs(Click to display name)') {
  137. map.removeLayer(popVdc);
  138. } else {
  139. }
  140. });
  141. </script>
  142. </body>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement