gpt4 book ai didi

javascript - 如何在可拖动的多边形上拉长?

转载 作者:行者123 更新时间:2023-11-30 06:50:28 24 4
gpt4 key购买 nike

<分区>

我想在拖动或编辑多边形时获取纬度和经度。我如何将事件监听器应用于此多边形,以便每当我编辑或拖动多边形时,它应该在我在多边形上编辑的每个点的控制台上显示经纬度。

function initialize() {
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 15,
center: {lat: 51.476706, lng: 0},
mapTypeId: google.maps.MapTypeId.ROADMAP
});

// create an array of coordinates for a pentagonal polygon
var arrCoords = [
new google.maps.LatLng(51.474821, -0.001935),
new google.maps.LatLng(51.474647, 0.003966),
new google.maps.LatLng(51.477708, 0.004073),
new google.maps.LatLng(51.479753, 0.000468),
new google.maps.LatLng(51.477654, -0.002192)
];

var polygon = new google.maps.Polygon({
editable: true,
paths: arrCoords,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35,
map: map
});
}

google.maps.event.addDomListener(window, 'load', initialize);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com