index.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Leaflet GeoJSON Example</title>
  5. <meta charset="utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
  8. </head>
  9. <body>
  10. <div id="map" style="width: 1200px; height: 700px"></div>
  11. <script src="tr-hydrant.js" type="text/javascript"></script>
  12. <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
  13. <script>
  14. var map = L.map('map').setView([48.9547, 10.9083], 16);
  15. L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
  16. attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  17. }).addTo(map);
  18. function onEachFeature(feature, layer) {
  19. var popupContent = "<p>" + feature.geometry.type + "</p>";
  20. if (feature.properties && feature.properties.popupContent) {
  21. popupContent += feature.properties.popupContent;
  22. }
  23. layer.bindPopup(popupContent);
  24. }
  25. L.geoJson(regions, {
  26. style: function (feature) {
  27. st = { weight: 1, color: "#000", opacity: 1, fillColor: "#ff0", fillOpacity: 0.5 }
  28. if(feature.properties.done) {
  29. st["fillColor"] = "#dc0067";
  30. }
  31. if(feature.properties.outdoor) {
  32. st["weight"] = 0;
  33. }
  34. return st
  35. },
  36. onEachFeature: onEachFeature,
  37. pointToLayer: function (feature, latlng) {
  38. return L.circleMarker(latlng, {
  39. radius: 8,
  40. fillColor: "#ff7800",
  41. color: "#000",
  42. weight: 1,
  43. opacity: 1,
  44. fillOpacity: 0.8
  45. });
  46. }
  47. }).addTo(map);
  48. </script>
  49. </body>
  50. </html>