Created
January 10, 2019 00:03
-
-
Save ketimaBU/184c3dd9963c5231aafa08d7694d36f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title></title> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" /> | |
| <link rel="stylesheet" href="../node_modules/leaflet-draw/dist/leaflet.draw.css" /> | |
| <link rel="stylesheet" href="../src/css/leaflet.draw.topology.css"/> | |
| <style> | |
| #map { | |
| height: 600px; | |
| } | |
| .custom-control { | |
| background-color: #fff; | |
| padding: 10px; | |
| text-align: center; | |
| border-radius: 4px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="map"></div> | |
| <script src="../node_modules/leaflet/dist/leaflet.js"></script> | |
| <script src="../node_modules/leaflet-draw/dist/leaflet.draw-src.js"></script> | |
| <script src="../node_modules/leaflet-geometryutil/src/leaflet.geometryutil.js"></script> | |
| <script src="../node_modules/Leaflet.Snap/leaflet.snap.js"></script> | |
| <script src="../src/js/leaflet.draw.topology.js"></script> | |
| <script src="lib/zepto.min.js"></script> | |
| <script type="text/javascript"> | |
| var map = new L.map("map").setView([38.5, -105], 6); | |
| L.tileLayer('http://{s}.acetate.geoiq.com/tiles/acetate/{z}/{x}/{y}.png', { | |
| maxZoom: 18, | |
| attribution: ' ©2012 Esri & Stamen, Data from OSM and Natural Earth' | |
| }).addTo(map); | |
| $.getJSON("data.geojson", function(data) { | |
| var geojson = L.geoJson(data, { | |
| style: { | |
| fillColor: '#000', | |
| color: '#444', | |
| weight: 2, | |
| opacity: 0.8 | |
| } | |
| }).addTo(map); | |
| // Init leaflet.draw.topology here with | |
| L.Edit.Topology.init(map, geojson, { | |
| "icon": new L.Icon({ | |
| iconUrl: '../src/icons/marker_blk.svg', | |
| iconSize: [12, 12] | |
| }) | |
| }); | |
| }); | |
| var instructions = L.Control.extend({ | |
| options: { | |
| position: 'topright' | |
| }, | |
| onAdd: function (map) { | |
| var container = L.DomUtil.create("div", "custom-control"); | |
| container.innerHTML += "Click on a polygon to enable editing.<br>Clicking on a line segment will add a new vertex."; | |
| return container; | |
| } | |
| }); | |
| map.addControl(new instructions()); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment