第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用傳單在地圖上繪制形狀

無法使用傳單在地圖上繪制形狀

繁星淼淼 2022-11-03 15:20:12
我正在使用 javascript 庫傳單來處理地圖,我現(xiàn)在做了位置搜索部分,我希望用戶可以在地圖上繪制圓、線和多邊形,但無法正常工作。搜索工具欄可見,但形狀不可見。任何人都可以指出我的代碼中的錯誤,在此先感謝。這是我的代碼:<!DOCTYPE html><html><head>  <!-- Load Leaflet from CDN-->  <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />  <script src="https://unpkg.com/leaflet/dist/leaflet-src.js"></script>  <!-- Load Esri Leaflet from CDN -->  <script src="https://unpkg.com/esri-leaflet"></script>  <!-- Esri Leaflet Geocoder -->  <link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder/dist/esri-leaflet-geocoder.css">  <script src="https://unpkg.com/esri-leaflet-geocoder"></script>  <script src="node_modules/leaflet-toolbar/dist/leaflet.toolbar.js"></script>  <link rel="stylesheet" href="node_modules/leaflet-toolbar/dist/leaflet.toolbar.css" />  <link rel="stylesheet" href="node_modules/leaflet-draw-toolbar/dist/leaflet.draw-toolbar.css" />  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>  <!----    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>    <script src="../node_modules/leaflet/dist/leaflet-src.js"></script>    <script src="../node_modules/leaflet-toolbar/dist/leaflet.toolbar-src.js"></script>    <script src="../node_modules/leaflet-draw/dist/leaflet.draw-src.js"></script>--!-->  <style>
查看完整描述

1 回答

?
慕桂英546537

TA貢獻1848條經(jīng)驗 獲得超10個贊

使用錯誤


var results = L.layerGroup.addTo(map);

應該


var results = new L.LayerGroup().addTo(map);

(就像您在搜索容器中所做的那樣)


<!DOCTYPE html>

<html>


<head>

  <!-- Load Leaflet from CDN-->

  <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />

  <script src="https://unpkg.com/leaflet/dist/leaflet-src.js"></script>


  <!-- Load Esri Leaflet from CDN -->

  <script src="https://unpkg.com/esri-leaflet"></script>


  <!-- Esri Leaflet Geocoder -->

  <link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder/dist/esri-leaflet-geocoder.css">

  <script src="https://unpkg.com/esri-leaflet-geocoder"></script>

  <script src="node_modules/leaflet-toolbar/dist/leaflet.toolbar.js"></script>


  <link rel="stylesheet" href="node_modules/leaflet-toolbar/dist/leaflet.toolbar.css" />

  <link rel="stylesheet" href="node_modules/leaflet-draw-toolbar/dist/leaflet.draw-toolbar.css" />

  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  <!----    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

    <script src="../node_modules/leaflet/dist/leaflet-src.js"></script>

    <script src="../node_modules/leaflet-toolbar/dist/leaflet.toolbar-src.js"></script>

    <script src="../node_modules/leaflet-draw/dist/leaflet.draw-src.js"></script>--!-->


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css" />

  <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>

  <script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>

  <style>

    #map {

      position: absolute;

      top: 0;

      bottom: 0;

      left: 0;

      right: 0;

    }

  </style>

</head>


<body>

  <div id="map"> </div>

  <script>

    var center = [-33.8650, 151.2094];


    var map = L.map('map').setView([0, 0], 6);

    drawnItems = new L.FeatureGroup().addTo(map);


    L.tileLayer('https://api.maptiler.com/maps/streets/{z}/{x}/{y}.png?key=eL1sdTPWF7XeyxpLvpGq', {


      attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>'


    }).addTo(map);


    var searchContrl = L.esri.Geocoding.geosearch().addTo(map);


    //adding layergroup to search control

    console.log(L.LayerGroup);

    var results = new L.LayerGroup().addTo(map);


    searchContrl.on('results', function(data) {

      results.clearLayers();

      for (var i = data.results.length - 1; i >= 0; i--) {

        results.addLayer(L.marker(data.results[i].latlong));

      }

    });


    var editableLayers = new L.FeatureGroup();

    map.addLayer(editableLayers);


    var MyCustomMarker = L.Icon.extend({

      options: {

        shadowUrl: null,

        iconAnchor: new L.Point(12, 12),

        iconSize: new L.Point(24, 24),

        iconUrl: 'link/to/image.png'

      }

    });


    var options = {

      position: 'topright',

      draw: {

        polyline: {

          shapeOptions: {

            color: '#f357a1',

            weight: 10

          }

        },

        polygon: {

          allowIntersection: false, // Restricts shapes to simple polygons

          drawError: {

            color: '#e1e100', // Color the shape will turn when intersects

            message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect

          },

          shapeOptions: {

            color: '#bada55'

          }

        },

        circle: false, // Turns off this drawing tool

        rectangle: {

          shapeOptions: {

            clickable: false

          }

        },

        marker: {

          icon: new MyCustomMarker()

        }

      },

      edit: {

        featureGroup: editableLayers, //REQUIRED!!

        remove: false

      }

    };


    var drawControl = new L.Control.Draw(options);

    map.addControl(drawControl);


    map.on(L.Draw.Event.CREATED, function(e) {

      var type = e.layerType,

        layer = e.layer;


      if (type === 'marker') {

        layer.bindPopup('A popup!');

      }


      editableLayers.addLayer(layer);

    });

  </script>

</body>


</html>


順便說一句,我使用var了因為你的語法,但const更好let。


查看完整回答
反對 回復 2022-11-03
  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號