C#GMapRoute为null,我不绘制路线

时间:2019-03-01 19:06:58

标签: c# google-maps routing

我正在使用Gmap.Net.WindowsForm,但是GMapRoute为null,并且没有进行图形布线,GMapRoute给出了NullReference错误。

GMapOverlay routeshow = new GMapOverlay("yeni rotasyon");
end = new PointLatLng(37.790658, 28.014990);
first = new PointLatLng(37.790658, 29.014990);
//Rotasyon Belirleme
GDirections direction;
var route = GMapProviders.GoogleMap.GetDirections(out direction, first, end, false, false, false, false, false);
GMapRoute routes = new GMapRoute(direction.Route, "routes"); // error happens here
routeshow.Routes.Add(routes);
gMapControl1.Overlays.Add(routeshow);
gMapControl1.Zoom = gMapControl1.Zoom + 1;
gMapControl1.Zoom = gMapControl1.Zoom - 1;

1 个答案:

答案 0 :(得分:0)

0需要指向其路线的点,这些点的类型为tank + 1。解决该问题将起作用。

GMapRoute routes = new GMapRoute(points, "routes")

每个代码都是这样的。

PointLatLng