gpt4 book ai didi

javascript - map - 折线根据速度改变颜色

转载 作者:行者123 更新时间:2023-11-28 07:01:45 24 4
gpt4 key购买 nike

enter image description here我有一个由 3 个不同级别的颜色组成的数组,其速度范围在

值之间
  1. 少于 60
  2. 60 到 80 之间
  3. 超过 120 个。

我可以将每个 lat long 放入一个数组中,其中速度是 3 个选项之一,并为每个选项使用不同的颜色,但是我注意到,例如,如果我的速度小于 60 作为起点,然后只有最后也有,开头的小于 60 将与末尾的小于 60 连接,因此画一条直线,有没有办法可以根据最小距离连接折线,即使我使用小于 60 的数组中的不同缩放级别点 Y 将连接到点 Z(下一个点),因为它不知道中间的其他两个数组。

var myTripGoing60 = [];
for (i = 0; i < latlngdataGoing60.length; i = i + 2) {
var point = new google.maps.LatLng(latlngdataGoing60[i], latlngdataGoing60[i + 1]);
myTripGoing60.push(point);
}

var myTripGoing6080 = [];
for (i = 0; i < latlngdataGoing6080.length; i = i + 2) {
var point = new google.maps.LatLng(latlngdataGoing6080[i], latlngdataGoing6080[i + 1]);
myTripGoing6080.push(point);
}


var myTripGoing120 = [];
for (i = 0; i < latlngdataGoing120.length; i = i + 2) {
var point = new google.maps.LatLng(latlngdataGoing120[i], latlngdataGoing120[i + 1]);
myTripGoing120.push(point);
}


var flightPath = new google.maps.Polyline({
path: myTripGoing60,
strokeColor: "#000000",
strokeOpacity: 0.8,
strokeWeight: 7
});
flightPath.setMap(map);

var flightPath = new google.maps.Polyline({
path: myTripGoing6080,
strokeColor: "#99FF00",
strokeOpacity: 0.8,
strokeWeight: 7
});
flightPath.setMap(map);

var flightPath = new google.maps.Polyline({
path: myTripGoing120,
strokeColor: "#003300",
strokeOpacity: 0.8,
strokeWeight: 7
});
flightPath.setMap(map);

最佳答案

enter image description here

我使用标记(点)而不是折线 - 现在就可以了。

关于javascript - map - 折线根据速度改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32077278/

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