Routing Errors since upgrading to today's WinForms build

Topics: Bugs
Jan 30, 2012 at 1:42 PM

Hi RadioMan,

Loving GMap.Net :) - a quick issue I've run into today...

Just tried out the latest hot build (Jan 30th Beta) on WinForms. Everything working prior to upgrading (original build was an October one). The latest build gives me errors as follows...

            PointLatLng? start = GMaps.Instance.GetLatLngFromGeocoder(textEditStartLocation.Text, out status);

Error 40 'GMap.NET.GMaps' does not contain a definition for 'GetLatLngFromGeocoder' and no extension method 'GetLatLngFromGeocoder' accepting a first argument of type 'GMap.NET.GMaps' could be found (are you missing a using directive or an assembly reference?)

Also,

            MapRoute route = GMaps.Instance.GetRouteBetweenPoints((PointLatLng)start, (PointLatLng)end, false, (int)myMap.Zoom);

Error 42 'GMap.NET.GMaps' does not contain a definition for 'GetRouteBetweenPoints' and no extension method 'GetRouteBetweenPoints' accepting a first argument of type 'GMap.NET.GMaps' could be found (are you missing a using directive or an assembly reference?)

I guess some methods have been moved or rename since the October version - can you advise on what I should be calling instead of those 2 methods?

Many thanks

Charlotte

Coordinator
Jan 30, 2012 at 1:50 PM

GMapProviders.GoogleMap.GetPoint/etc, there is routing implemented in openstreetmap provider too

Jan 30, 2012 at 2:09 PM

Hi Radioman.

Firstly, many thanks for your super quick reply :)

I had a look through the latest demo code and solved the first issue using the code in the demo app.

 

For the second issue,

I've coded the following...

            List<PointLatLng> points = new List<PointLatLng>();

            points.Add((PointLatLng)start);

            points.Add((PointLatLng)end);

            MapRoute route = new GMapRoute(points, "Route");

 

            if (route != null)

            {

                // add route

                GMapRoute r = new GMapRoute(route.Points, route.Name);

                routes.Routes.Add(r);

                // add route start/end marks

                GMapMarker m1 = new GMarkerGoogle((PointLatLng)start, GMarkerGoogleType.green);

                m1.ToolTipText = "Start: " + route.Name;

                m1.ToolTipMode = MarkerTooltipMode.Always;

                m1.Tag = "RouteStart" // store value in tag so we can find it for deleting //

 

                GMapMarker m2 = new GMarkerGoogle((PointLatLng)end, GMarkerGoogleType.red);

                m2.ToolTipText = "End: " + end.ToString();

                m2.ToolTipMode = MarkerTooltipMode.Always;

                m2.Tag = "RouteEnd"// store value in tag so we can find it for deleting // 

                objects.Markers.Add(m1);

                objects.Markers.Add(m2);

                myMap.ZoomAndCenterRoute(r);

            }

The problem with this is that it draws a straight line between the start and end - it doesn't follow any roads. What have I done wrong here - is it something to do with  new GMapRoute(points, "Route"); - I put in "Route" as I have no idea what the string parameter is for - I'm gusing it's just a name for it?

Thanks

Charlotte.

Coordinator
Jan 30, 2012 at 2:19 PM

you get exactly what you asked for, line between two points ;}

Jan 30, 2012 at 3:02 PM

Fair enough ;-)

How do I alter the code to draw along the shortest road then?

Thanks.

Jan 30, 2012 at 3:22 PM

Figured it out...

Changed

MapRoute route = new GMapRoute(points, "Route");

To

MapRoute route = GMapProviders.GoogleMap.GetRoute((PointLatLng)start, (PointLatLng)end, false, false, (int)myMap.Zoom);

:-)