Javascript 开放层3-沿道路绘制路线
我有一个web服务,它返回两点之间路线的坐标列表Javascript 开放层3-沿道路绘制路线,javascript,openlayers-3,Javascript,Openlayers 3,我有一个web服务,它返回两点之间路线的坐标列表 if (points.length > 0) { var routeLayer = new ol.layer.Vector({ source: new ol.source.Vector({ features: [new ol.Feature({ geometry: new ol.geom.LineString(points, 'XY') })] }), sty
if (points.length > 0) {
var routeLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({ geometry: new ol.geom.LineString(points, 'XY') })]
}),
style: new ol.style.Style({
fill: new ol.style.Fill({ color: '#0091ea', weight: 8 }),
stroke: new ol.style.Stroke({ color: '#0091ea', width: 4 })
}),
name: 'routeLayer'
});
map.addLayer(routeLayer);
}
我遇到的问题是,web服务仅在用户需要转弯、到达环形交叉口或交叉口时返回点。这将导致在点之间绘制直线,当道路弯曲时,这些点看起来不正确
有没有一种方法可以只沿着道路绘制路线,或者是唯一的选择(使用OL3)让web服务返回更多的点来说明弯曲的道路
OL3对这个项目来说并不是必不可少的,但它是我们迄今为止一直在使用的,所以坚持使用它会更好 您必须获得更多的点才能更准确地绘制路线。您可以使用mmGetCurvePoints()函数来绘制此链接中具有2点或3点的曲线: