0

I'm developing a UWP application with a map functionality. I've Rout drawing feature and I've a problem in this feature.

Here is my code (which was full functional in WP 8.1)

public async Task DrawRouteOnMap(double StartLong, double StartLat, double EndLong, double EndLat)
    {
        // Start at Grand Central Station.
        BasicGeoposition startLocation = new BasicGeoposition();
        startLocation.Latitude = StartLat;
        startLocation.Longitude = StartLong;
        Geopoint startPoint = new Geopoint(startLocation);
        // End at Central Park.
        BasicGeoposition endLocation = new BasicGeoposition();
        endLocation.Latitude = EndLat;
        endLocation.Longitude = EndLong;
        Geopoint endPoint = new Geopoint(endLocation);
        // Get the route between the points.
        MapRouteFinderResult routeResult =
        await MapRouteFinder.GetDrivingRouteAsync(
          startPoint,
          endPoint,
          MapRouteOptimization.Distance,
          MapRouteRestrictions.None,
          290);

        if (routeResult.Status == MapRouteFinderStatus.Success)
        {
            // Use the route to initialize a MapRouteView.
            MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
            viewOfRoute.RouteColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);
            viewOfRoute.OutlineColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);

            //await new Windows.UI.Popups.MessageDialog(viewOfRoute.Route.EstimatedDuration.ToString()).ShowAsync();
            // Add the new MapRouteView to the Routes collection
            // of the MapControl.
            mapControl.Routes.Add(viewOfRoute);
            // Fit the MapControl to the route.
            await mapControl.TrySetViewBoundsAsync(
              routeResult.Route.BoundingBox,
              null,
              MapAnimationKind.Linear);
        }
    }

The result of this code here is

StartPointNotFound

I've try a static location also with no hope.

Thanks in advance

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
OXXY
  • 1,047
  • 2
  • 18
  • 43
  • what is your start location that you are using? – rbrundritt Mar 24 '16 at 15:13
  • @rbrundritt My current location from the location service – OXXY Mar 24 '16 at 17:34
  • Ok. I would then guess that you are near a road. If you were a distance away from a road, then it may not find a route that can be used. Maybe add a breakpoint and take a look at the latitude and longitude values of the start point. Ensure latitude is between -90 and 90, and longitude is between -180 and 180. – rbrundritt Mar 24 '16 at 19:15
  • @rbrundritt actually I did, I also tried a static (valid) values but with no hope – OXXY Mar 25 '16 at 16:32
  • This code does work, did you find the issue? I do not understand StartPointNotFound, where does it come from, there is no variable named StartPoint for example.? can you please be more specific when asking questions then you should get a quick answer. An incorrect Long/Lat would throw an exception so nothing makes sense without more detail. – 27k1 May 03 '16 at 18:27
  • @peterincumbria Thank you for you comment. First the "StartPointNotFound" msg return as a response from the routeResult status. Second I've tried a static (valid) values as I mentioned in the comments but with no hope. Finally I thought the question is specific and clear sorry for inconvenient. – OXXY May 04 '16 at 05:16
  • No probs, this error means that the start point is too far from a road. Perhaps draw an icon with this start point to find out exactly where it is. Change to GetWalkingRouteFromWaypointsAsync, see if this works, MapRouteFinder always glues itself to the nearest path unlike polylines. Hope this helps. PS. I have the same code in my route app. – 27k1 May 04 '16 at 07:31

0 Answers0