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

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

不理解傳單中 latLngBounds 的語法

不理解傳單中 latLngBounds 的語法

絕地?zé)o雙 2022-08-27 10:57:51
傳單latLngBounds()函數(shù)有一個(gè)getCenter()方法,但我不明白返回該值的語法。var mk5 = L.latLngBounds.getCenter(); returns an errorvar mk5 = L.latLngBounds().getCenter(); returns an errorvar mk5 = L.latLngBounds({getCenter()}); returns an error找到其使用的例子是不可能的。有人請告訴我使用此方法的語法。
查看完整描述

1 回答

?
三國紛爭

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊

文檔所示:

  1. 創(chuàng)建第一個(gè)角:var corner1 = L.latLng(40.712, -74.227);

  2. 創(chuàng)建第二個(gè)角:var corner2 = L.latLng(40.774, -74.125);

  3. 創(chuàng)建邊界:bounds = L.latLngBounds(corner1, corner2);

  4. 從實(shí)例調(diào)用方法:getCenterboundsbounds.getCenter()

下面是一個(gè)示例:

<!DOCTYPE html>

<html>


  <head>


    <title>Quick Start - Leaflet</title>


    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />


    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin="" />

    <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>




  </head>


  <body>




    <div id="mapid" style="width: 600px; height: 400px;"></div>

    <script>

      var mymap = L.map('mapid').setView([51.505, -0.09], 2);


      L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {

        maxZoom: 18,

        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +

          '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +

          'Imagery ? <a href="https://www.mapbox.com/">Mapbox</a>',

        id: 'mapbox/streets-v11',

        tileSize: 512,

        zoomOffset: -1

      }).addTo(mymap);


      var corner1 = L.latLng(40.712, -74.227),

        corner2 = L.latLng(40.774, -74.125),

        bounds = L.latLngBounds(corner1, corner2)


      var rect = L.rectangle(bounds, {

        color: 'blue',

        weight: 1

      }).addTo(mymap);


      mymap.fitBounds(bounds)



      const markerCoords = bounds.getCenter()


      L.marker(markerCoords).addTo(mymap)


    </script>




  </body>


</html>


查看完整回答
反對 回復(fù) 2022-08-27
  • 1 回答
  • 0 關(guān)注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

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