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

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

如何使用谷歌地圖獲取一個(gè)地方的坐標(biāo)

如何使用谷歌地圖獲取一個(gè)地方的坐標(biāo)

躍然一笑 2022-09-23 16:41:27
我有一個(gè)地址,我想在地圖上顯示它,并得到拉特/lng   <body>    <div id="floating-panel">          <input id="address" type="textbox" value="Sydney, NSW">          <input id="submit" type="button" value="Geocode">        </div>        <div id="map"></div>        <script>          function initMap() {            var map = new google.maps.Map(document.getElementById('map'), {              zoom: 8,              center: {lat: -34.397, lng: 150.644}            });            var geocoder = new google.maps.Geocoder();            document.getElementById('submit').addEventListener('click', function() {              geocodeAddress(geocoder, map);            });          }          function geocodeAddress(geocoder, resultsMap) {            var address = document.getElementById('address').value;            geocoder.geocode({'address': address}, function(results, status) {              if (status === 'OK') {                resultsMap.setCenter(results[0].geometry.location);                //////////////////////////////////////////                console.log(results[0].geometry.location);                //////////////////////////////////////////                var marker = new google.maps.Marker({                  map: resultsMap,                  position: results[0].geometry.location                });              } else {                alert('Geocode was not successful for the following reason: ' + status);              }            });          }        </script>        <script async defer        src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">        </script>      </body>我得到了這個(gè):地圖工作正常,但我不能得到lng /拉特。我如何使用地圖JavaScript API獲得它,或者我必須使用其他地圖API,如地理編碼API
查看完整描述

1 回答

?
萬(wàn)千封印

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

從您自己的屏幕截圖中可以看出,為了檢索緯度/經(jīng)度的計(jì)算值,您需要將這些屬性視為函數(shù)。

let latVal = results[0].geometry.location.lat();
let lngVal = results[0].geometry.location.lng();


查看完整回答
反對(duì) 回復(fù) 2022-09-23
  • 1 回答
  • 0 關(guān)注
  • 190 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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