【发布时间】:2017-08-04 17:15:10
【问题描述】:
{
"type":"FeatureCollection",
"generator":"JOSM",
"features":[
{
"type":"Feature",
"properties":{
},
"geometry":{
"type":"LineString",
"coordinates":[
[
121.54821846780,
24.98741107673
],
[
121.54812039953,
24.98739360280
],
[
121.54812750162,
24.98736155308
],
[
121.54813477853,
24.98732871440
],
[
121.54814403650,
24.98728693577
]
]
}
},
{
"type":"Feature",
"properties":{
},
"geometry":{
"type":"LineString",
"coordinates":[
[
121.54813477853,
24.98732871440
],
[
121.54819734540,
24.98733966151
],
[
121.54819365737,
24.98735561598
]
]
}
},
{
"type":"Feature",
"properties":{
},
"geometry":{
"type":"LineString",
"coordinates":[
[
121.54812750162,
24.98736155308
],
[
121.54780189872,
24.98730374867
],
[
121.54776282754,
24.98729681235
]
]
}
}
]
这是Geojson路径,我怎么画两点,路径会沿着这条路径走? 我用 JOSM 画画。
if (route == true) {
start = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(point.getLatitude(), point.getLongitude())).title("start").icon(icon));
route = false;
} else {
if(destination!=null){
mapboxMap.removeMarker(destination);
}
destination = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(point.getLatitude(), point.getLongitude())).title("finish"));
LatLng[] points = new LatLng[2];
LatLng loc = new LatLng(start.getPosition());
LatLng dest = new LatLng(destination.getPosition());
points[0] = loc;
points[1] = dest;
if (poly != null) {
mapboxMap.removePolyline(poly);
}
poly = mapboxMap.addPolyline(new PolylineOptions()
.add(points)
.color(Color.parseColor("#3887be"))
.width(5));
}
路线是直线,我想在我的 Geojson 路径上绘制路线,我该怎么做? 我希望两个标记跟随我的路径来规划最佳路径,我可以在 Android 上加载 Geojson 路径并在地图上绘制路径,但是我如何让两点跟随我的路径来创建路线?谢谢!
【问题讨论】: