gMap两点之间画路线和直线的方法

网上搜过画路线的方法,看到过两种方法直接调用GMapRoute的manager里面有个什么方法,自己写的时候总是找不到那个方法,后来朋友教了个方法,我试过后可以用

//画出两点之间的线路
private void DrawrouteBetweenTowPoint(PointLatLng pointLatLng_S,PointLatLng pointLatLng_E)
        {
            RoutingProvider rp = gMap.MapProvider as RoutingProvider;
            if(rp != null)
            {
                rp = GMapProviders.GoogleMap;
            }
            MapRoute route = rp.GetRoute(pointLatLng_S, pointLatLng_E, false, false, (int) gMap.Zoom);
            if(route!=null)
            {
                GMapRoute r =new GMapRoute(route.Points,route.Name);
                _overlay.Routes.Add(r);
             //   gMap.ZoomAndCenterRoute(r);
            }
        }
 //画出两点直接的直线
 private void DrawLineBetweenTwoPoint(PointLatLng pointLatLng_S,PointLatLng pointLatLng_E)
        {
            List points = new List();
            points.Add(pointLatLng_S);
            points.Add(pointLatLng_E);
            GMapRoute r = new GMapRoute(points, "");
            r.Stroke = new Pen(Color.Green, 1);
            _overlay.Routes.Add(r);
        }

你可能感兴趣的:(.NET)