Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var data = <?php  echo $defaultvaluepath ?>;
  2.         var mygeojson = {"type": "FeatureCollection","features":[data]};
  3.         // console.log(mygeojson);
  4.         var layerwilayah = L.geoJson(null);
  5.         layerwilayah.addData(mygeojson);
  6.         layerwilayah.addTo(map);
  7.  
  8.         // create fullscreen control
  9.         var fsControl = L.control.fullscreen();
  10.         // add fullscreen control to the map
  11.         map.addControl(fsControl);
  12.  
  13.         // detect fullscreen toggling
  14.         map.on('enterFullscreen', function(){
  15.             if(window.console) window.console.log('enterFullscreen');
  16.         });
  17.         map.on('exitFullscreen', function(){
  18.             if(window.console) window.console.log('exitFullscreen');
  19.         });
  20.  
  21.         var featureGroup = new L.FeatureGroup().addTo(map);
  22.         console.log(featureGroup);
  23.         map.addLayer(featureGroup);
  24.         var drawControl = new L.Control.Draw({
  25.             edit: {
  26.                 featureGroup: featureGroup,
  27.                 edit : true,
  28.             },
  29.             draw: {
  30.                 polyline: false,
  31.                 polygon: true,
  32.                 rectangle: false,
  33.                 circle: false,
  34.                 marker: false,
  35.                 circlemarker: false,
  36.          },
  37.         });
  38.         map.addControl(drawControl);
  39.  
  40.         map.on(L.Draw.Event.CREATED, function (event) {
  41.             var layer = event.layer;
  42.              
  43.  
  44.         });
  45.        
  46.         map.on('draw:created', function (e) {
  47.             var type = e.layerType,
  48.             layer = e.layer;
  49.             var drawnJSONObject = layer.toGeoJSON();
  50.             var objectGeometry = Terraformer.WKT.convert(drawnJSONObject.geometry);
  51.             if (type === 'polyline') {
  52.                 $('#path').val(JSON.stringify(drawnJSONObject));
  53.             } else if (type === 'polygon') {
  54.                 $('#path').val(JSON.stringify(drawnJSONObject));
  55.             } else {
  56.             console.log('__undefined__');
  57.             }
  58.             featureGroup.addLayer(layer);
  59.  
  60.         });
  61.        
  62.         map.on('draw:edited', function(e){
  63.  
  64.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement