我使用yandexmapkit-android处理项目。图书馆链接为https://github.com/yandexmobile/yandexmapkit-android
文档很弱,github页面不新鲜。最后更新是3年前。
我想画两点之间的路线,但我找不到任何这个或例子的功能或方法
你能帮助我吗?
答案 0 :(得分:0)
我可以看到,有两种方法可以做到。 第一个是将Yandex Navigator称为外部应用程序:https://github.com/yandexmobile/yandexmapkit-android/wiki/%D0%98%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B0%D1%86%D0%B8%D1%8F-%D1%81-%D0%9C%D0%BE%D0%B1%D0%B8%D0%BB%D1%8C%D0%BD%D1%8B%D0%BC%D0%B8-%D0%AF%D0%BD%D0%B4%D0%B5%D0%BA%D1%81.%D0%9A%D0%B0%D1%80%D1%82%D0%B0%D0%BC%D0%B8
第二种是使用带有WebView的Yandex JS API:https://tech.yandex.ru/maps/doc/jsapi/2.0/ref/reference/route-docpage/
答案 1 :(得分:0)
mtRouter = MapKitFactory.getInstance().createMasstransitRouter();
mtRouter.requestRoutes(ROUTE_START_LOCATION, ROUTE_END_LOCATION,
new MasstransitOptions(new ArrayList<String>(), new ArrayList<String>(),
// Specify departure time or arrival time here
new TimeOptions()),
this);
答案 2 :(得分:0)
// add points
List<RequestPoint> requestPoints = new ArrayList<>();
DrivingOptions drivingOptions = new DrivingOptions();
DrivingRouter drivingRouter = MapKitFactory.getInstance().createDrivingRouter();
DrivingSession drivingSession = drivingRouter.requestRoutes(
requestPoints, drivingOptions, new DrivingSession.DrivingRouteListener() {
@Override
public void onDrivingRoutes(List<DrivingRoute> routes) {
if (routes != null
&& !routes.isEmpty()) {
DrivingRoute route = routes.get(0);
BoundingBox box = BoundingBoxHelper.getBounds(route.getGeometry());
CameraPosition boundingBoxPosition = yandexMap.getMap()
.cameraPosition(box);
}
}
@Override
public void onDrivingRoutesError(Error error) {
//showErrorMessage }
});
您可以轻松使用此方法并设置相机位置
希望它对您有用