这是我创建多个航点的代码。 我有一个纬度和经度为'n'的数组,我希望基于该纬度,经度的路线。我不想在航点中使用任何硬核数据。 在航点数组中,我想使用动态纬度和经度,该如何使用?
var data = [
{
"title": 'Chennai',
"lat": '13.0827',
"lng": '80.2707',
"description": '',
"flag":'1'
}
,
{
"title": 'Ramapuram',
"lat": '13.0317',
"lng": '80.1817',
"description": ''
}
,
{
"title": 'Kanchipuram',
"lat": '12.8342',
"lng": '79.7036',
"description": '',
"flag":'1'
},
];
var map = L.map('map');
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var routeControl = L.Routing.control({
}).addTo(map);
routeControl.setWaypoints(data);
我在这里附加了图像,这是我的输出,我的期望也是我要删除中心标记。我想在所需位置设置标记。
有人可以帮我吗?现在,我更新了删除航路点并使用setwaypoints函数设置航路点的代码。现在我想删除标记。
答案 0 :(得分:0)
如果我理解正确,您想沿着一些航点绘制路线并仅显示起点和终点的标记。您还想阻止用户添加新的航点。创建这样的控件:
L.Routing.control({
waypoints: yourWaypoints,
plan: L.Routing.plan(yourWaypoints, {
createMarker: function(i, wp, n) {
if (i == 0 || i == n - 1) {
return L.marker(wp.latlng, {
draggable: false // prevent users from changing waypoint position
});
} else {
return false;
}
}
},
addWaypoints: false // prevent users from adding new waypoints
});