【问题标题】:How to create a route in Gmap.net wpf?如何在 Gmap.net wpf 中创建路线?
【发布时间】:2016-05-26 05:51:12
【问题描述】:

我希望你能帮助我。我在网络上找不到任何对 GMap.net 的 WPF 版本有帮助的东西。

问题:我没有看到我的路线。

List<Location> points = PolylinePoint.Decode(responseData.routes.First().overview_polyline.points);

GMap.NET.WindowsPresentation.GMapRoute route = new GMap.NET.WindowsPresentation.GMapRoute(points.Select(x => new PointLatLng(x.Latitude.Value, x.Longitude.Value)));
route.ZIndex = ROUTESLIST;
route.Shape = new Line() { StrokeThickness = 4, Stroke = System.Windows.Media.Brushes.BlueViolet };
this.routenList.Clear();
this.routenList.Add(route);

主要问题是,我不能像 GMap.NET 教程中那样使用叠加层。

有什么建议吗?

【问题讨论】:

  • project site 确实有很多示例,也适用于 WPF 中的路由。
  • 为了提供更多帮助,请提供更多您所做的工作,特别是让我们知道routenlistROUTESLIST 代表什么。

标签: c# wpf gmap.net


【解决方案1】:

一般的做法是添加一个marker,将路由点添加到marker的Route

var track = new List<PointLatLng>();

// add PointLatLngs to 'track' here

var routeMarker = new GMapMarker(track.First());
routeMarker.Route.AddRange(track);

// don't forget to add the marker to the map
_mapControl.Markers.Add(routeMarker);

【讨论】:

  • Route 属性从何而来?
【解决方案2】:
    RoutingProvider routingProvider = 
       _map.MapProvider as RoutingProvider ?? GMapProviders.OpenStreetMap;

    MapRoute route = routingProvider.GetRoute(
        new PointLatLng(35.834914, -76.009508), //start
        new PointLatLng(35.854914, -76.009508), //end
        false, //avoid highways 
        false, //walking mode
        (int)_map.Zoom);

    GMapRoute gmRoute = new GMapRoute(route.Points);

    _map.Markers.Add(gmRoute);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    • 2017-12-22
    • 2023-02-17
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多