gpt4 book ai didi

c# - GMap.NET 路由返回 null

转载 作者:太空狗 更新时间:2023-10-29 22:36:44 25 4
gpt4 key购买 nike

我正在使用 C# 开发一个程序,我想计算路线,但它返回 null。

这是我的代码;

PointLatLng start = new PointLatLng(38.481858, 27.089006);
PointLatLng end = new PointLatLng(38.468447, 27.113793);

MapRoute route = GMap.NET.MapProviders.GoogleMapProvider
.Instance.GetRoute(start, end, false, false, 15);
GMapRoute r = new GMapRoute(route.Points , "My route");
GMapOverlay routeOverlay = new GMapOverlay("route");
routeOverlay.Routes.Add(r);
gMap.Overlays.Add(routeOverlay);
double distance;
distance = route.Distance;

r.Stroke.Width = 2;
r.Stroke.Color = Color.OrangeRed;

我不知道我哪里出错了。任何形式的帮助将不胜感激。

最佳答案

GDirections ss;
var xx = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, false, false, false);
GMapRoute r = new GMapRoute(ss.Route, "My route");

试试这个...

关于c# - GMap.NET 路由返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31693023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com