Advertisement
piersoft

unescomap

Jan 25th, 2014
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. <?php
  2.  
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="it">
  6. <head>
  7. <title>List of World Heritage Sites</title>
  8. <link rel="stylesheet" href="http://necolas.github.io/normalize.css/2.1.3/normalize.css" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  10. <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
  11. <link rel="stylesheet" href="MarkerCluster.css" />
  12. <link rel="stylesheet" href="MarkerCluster.Default.css" />
  13. <script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
  14. <script src="leaflet.markercluster.js"></script>
  15. <script type="text/javascript">
  16. function microAjax(B,A){this.bindFunction=function(E,D){return function(){return E.apply(D,[D])}};this.stateChange=function(D){if(this.request.readyState==4){this.callbackFunction(this.request.responseText)}};this.getRequest=function(){if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP")}else{if(window.XMLHttpRequest){return new XMLHttpRequest()}}return false};this.postBody=(arguments[2]||"");this.callbackFunction=A;this.url=B;this.request=this.getRequest();if(this.request){var C=this.request;C.onreadystatechange=this.bindFunction(this.stateChange,this);if(this.postBody!==""){C.open("POST",B,true);C.setRequestHeader("X-Requested-With","XMLHttpRequest"); C.setRequestHeader("Content-type","application/x-www-form-urlencoded");C.setRequestHeader("Connection","close")}else{C.open("GET",B,true)}C.send(this.postBody)}};
  17. </script>
  18. <style>
  19. #mapdiv{
  20. position:fixed;
  21. top:0;
  22. right:0;
  23. left:0;
  24. bottom:0;
  25. }
  26. #loading {
  27. position:fixed;
  28. top:0;
  29. left:0;
  30. width:100%;
  31. height:100%;
  32. background-color:#666;
  33. color:#fff;
  34. font-size:1em;
  35. padding:10% 40px;
  36. z-index:10;
  37. text-align:center;
  38. }
  39. #infodiv{
  40. background-color: rgba(255, 255, 255, 0.95);
  41.  
  42. border-width: 2px;
  43. border-style: solid;
  44. border-color: rgba(255, 255, 255, 0.8);
  45.  
  46. border-radius: 9px;
  47.  
  48. padding: 10px;
  49.  
  50. //width: 90%;
  51. font-size: 11px;
  52. botton: 2px;
  53. left: 2px;
  54.  
  55. bottom: 20px;
  56. max-height: 50px;
  57.  
  58. position: fixed;
  59.  
  60. overflow-y: auto;
  61. overflow-x: hidden;
  62. }
  63. </style>
  64. </head>
  65.  
  66. <body>
  67.  
  68. <div id="mapdiv"></div>
  69. <script type="text/javascript">
  70. var lat=40.662617,
  71. lon=16.6191,
  72. zoom=2;
  73. var osm = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {maxZoom: 19, attribution: 'Map Data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors | @Piersoft from <a href="http://whc.unesco.org/en/list/">UNESCO</a> list (25.01.14)'});
  74. var mapquest = new L.TileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {subdomains: '1234', maxZoom: 18, attribution: 'Map Data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors | @Piersoft from <a href="http://whc.unesco.org/en/list/">UNESCO</a> list (25.01.14)'});
  75.  
  76. var map = new L.Map('mapdiv', {
  77. editInOSMControl: true,
  78. editInOSMControlOptions: {
  79. position: "topright"
  80. },
  81. center: new L.LatLng(lat, lon),
  82. zoom: zoom,
  83. layers: [osm]
  84. });
  85.  
  86. var baseMaps = {
  87. "Mapnik": osm,
  88. "Mapquest Open": mapquest
  89. };
  90. L.control.layers(baseMaps).addTo(map);
  91.  
  92.  
  93.  
  94.  
  95. microAjax('unesco.json',function (res) {
  96. var feat=JSON.parse(res);
  97. loadLayer(feat);
  98.  
  99. } );
  100. var ico=L.icon({iconUrl:'logo_unesco.png', iconSize:[20,20],iconAnchor:[10,0]});
  101. var markers = L.markerClusterGroup();
  102.  
  103.  
  104. function loadLayer(url)
  105. {
  106.  
  107. var myLayer = L.geoJson(url,{
  108. onEachFeature:function onEachFeature(feature, layer) {
  109.  
  110. if (feature.properties) {
  111. var string='<div align="center"><img src="http://whc.unesco.org/uploads/sites/site_'+feature.properties.id_no+'.jpg"></div></br><b>';
  112. string +='Name:</b> '+feature.properties.name_en+'</br><b>Short description:</b> '+feature.properties.short_description_en+'<br/><b>Date inscribed:</b> '+feature.properties.date_inscribed+"<br/>";
  113. string +='<b>Category:</b> '+feature.properties.category+"<br/>"+'<b>State:</b> '+feature.properties.states_name_en;
  114.  
  115.  
  116. layer.bindPopup(string, {
  117. maxWidth: "200",
  118. maxHeight: "200",
  119. closeButton: false
  120. });
  121. }
  122. },
  123.  
  124. pointToLayer: function (feature, latlng) {
  125. var marker = new L.marker(latlng, { icon: ico });
  126. markers[feature.properties.id] = marker;
  127. return marker;
  128.  
  129. }
  130. }).addTo(markers);
  131.  
  132. markers.addLayer(myLayer);
  133.  
  134. }
  135.  
  136.  
  137.  
  138. map.addLayer(markers);
  139. map.fitBounds(markers.getBounds());
  140. </script>
  141.  
  142. </body>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement