gpt4 book ai didi

javascript - 使用多边形叠加将颜色设置为谷歌地图中的特定区域

转载 作者:行者123 更新时间:2023-11-28 02:09:16 27 4
gpt4 key购买 nike

我需要为谷歌地图的特定区域着色。我已经尝试过 polygon overlay example. 。这里的坐标使用方式如下:

var triangleCoords = [   
new google.maps.LatLng(23.8099144,90.40607589999999,0),
new google.maps.LatLng(24.8199144,86.40607589999999,0),
new google.maps.LatLng(25.8299144,92.40607589999999,0),
new google.maps.LatLng(23.8099144,90.40607589999999,0)
];

但是我有如下格式的区域坐标:

89.90277900000007,22.36819100000007,0 89.90277900000007,22.36833399999999,0 89.90334400000013,22.36861000000009,0 89.903611,22.36889000000003,0 89.90416700000004,22.36917099999998,0 89.90499900000009,22.37001000000014,0 89.90499900000009,22.37111000000006,0 89.905281,22.37138800000008,0 89.905281,22.37833300000009,0 89.90333500000007,22.37833300000009,0 89.90166400000005,22.37527899999996,0 89.901391,22.3750010000001,089.90166400000005,22.36944400000003,0 89.90166400000005,22.36929200000004,0 89.90166400000005,22.36916600000013,0 89.90110800000001,22.36861000000009,0 89.90132199999998,22.36829099999999,0 89.90135199999997,22.368179,0 89.901391,22.36805600000009,0 89.90277900000007,22.36805600000009,0 89.90277900000007,22.36819100000007,0

现在我如何在代码中使用该区域坐标值。该值来自数据库单个字段,很难将其一一合并到对象中,例如:

new google.maps.LatLng(89.90277900000007,22.36819100000007,0),
new google.maps.LatLng(89.90277900000007,22.36833399999999,0),
.
.
.
new google.maps.LatLng(89.90277900000007,22.36819100000007,0),

请给我一个合适的解决方案。

最佳答案

使用此代码...

var res = "89.90277900000007,22.36819100000007,....,0 89.90277900000007,22.36819100000007,0";
resArray = res.split(" ");
var triangleCoords = [];

for(var i=0; i<resArray.length; i++){
triangleCoords.push(new google.maps.LatLng(resArray[0]))
}

关于javascript - 使用多边形叠加将颜色设置为谷歌地图中的特定区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17342771/

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