我在yandexmapkit-android项目中工作。库链接为https://github.com/yandexmobile/yandexmapkit-android
文档非常薄弱,github页面也不新鲜。最近一次更新是在3年前。
我想在两个点之间绘制路径,但我找不到任何函数或方法来实现这一点或示例
你能帮我吗?
发布于 2016-04-06 00:48:37
正如我所见,有两种方法可以做到这一点。第一个是调用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/
发布于 2018-10-10 18:53:09
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);发布于 2018-10-31 22:04:37
// 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 }
});您可以很容易地使用此方法并设置相机位置
希望它能为你工作
https://stackoverflow.com/questions/31962456
复制相似问题