鉴于此功能,我想更换颜色与颜色随机发生器.
document.overlay = GPolyline.fromEncoded({
color: "#0000FF",
weight: 10,
points: encoded_points,
zoomFactor: 32,
levels: encoded_levels,
numLevels: 4
});
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我有一个来自谷歌地图的"地方"对象,它有一组坐标,代表一个给定位置的边界框,比如伦敦.每组坐标都有纬度和经度.
我写了下面的代码来找到中心点,但我不确定它是否确实产生了中心点.如果多边形有5个点而不是4个怎么办?此外,这可以通过更少的操作以更有效的方式完成吗?
function average(array) {
// Add together and then divide by the length
return _.reduce(array, function (sum, num) {
return sum + num;
}, 0) / array.length;
}
// I have a two-dimensional array that I want to get the average of
var coords = [
[ -1.2, 5.1 ],
[ -1.3, 5.2 ],
[ -1.8, 5.9 ],
[ -1.9, 5.8 ]
]
// So I get the first column
var lats = coords.map(function (coord) {
return coord[0];
}) …Run Code Online (Sandbox Code Playgroud)