示例#1
0
        public async Task SetUserLocationOnMap(Place userLocation)
        {
            currentLocation   = userLocation;
            btnNext.IsEnabled = true;

            if (navigationcompleted)
            {
                try
                {
                    await MapViewer.InvokeScriptAsync("setLocation", new string[] { currentLocation.Latitude.ToString(), currentLocation.Longitude.ToString(), currentLocation.Address });
                }
                catch (Exception ex)
                {
                    Util.HandleMessage("Locatin couldn't be set in map", ex.ToString(), "Error");
                }
            }
        }
示例#2
0
 private async Task ShowSingleRoutedirections()
 {
     try
     {
         if (Util.UserProfileData.CurrentPlace != null && selectedPlace != null)
         {
             await MapViewer.InvokeScriptAsync("calcRoute", new string[] { Util.UserProfileData.CurrentPlace.Latitude.ToString(),
                                                                           Util.UserProfileData.CurrentPlace.Longitude.ToString(),
                                                                           selectedPlace.Latitude.ToString(), selectedPlace.Longitude.ToString(),
                                                                           Util.UserProfileData.CurrentPlace.Address, selectedPlace.DisplayName });
         }
     }
     catch (Exception ex)
     {
         Util.HandleMessage("Map direction couldn't be loaded", ex.ToString(), "Error");
     }
 }
示例#3
0
        private async Task ShowBestPossibleRoutes()
        {
            try
            {
                //Show best possible route path
                if (Util.UserProfileData.CurrentPlace != null)
                {
                    await MapViewer.InvokeScriptAsync("Reset", null);

                    List <KeyValuePair <double, string> > places = new List <KeyValuePair <double, string> >();

                    foreach (var item in ProbableVisitedPlaces)
                    {
                        places.Add(new KeyValuePair <double, string>(
                                       CalculateDistance(Util.UserProfileData.StartPlace.Latitude, Util.UserProfileData.StartPlace.Longitude, item.Latitude, item.Longitude), item.UniqueId));
                    }

                    var maxdistance         = places.Max(p => p.Key);
                    var destinationUniqueId = places.Where(p => p.Key == maxdistance).Select(p => p.Value).First();
                    var destination         = ProbableVisitedPlaces.First(p => p.UniqueId == destinationUniqueId);

                    var waypoints = ProbableVisitedPlaces.Where(p => p.UniqueId != Util.UserProfileData.StartPlace.UniqueId && p.UniqueId != destinationUniqueId);
                    foreach (var point in waypoints)
                    {
                        await MapViewer.InvokeScriptAsync("createWayPoints", new string[] { point.Latitude.ToString(), point.Longitude.ToString(), point.DisplayName });
                    }

                    await MapViewer.InvokeScriptAsync("calcRoute", new string[] { Util.UserProfileData.StartPlace.Latitude.ToString(),
                                                                                  Util.UserProfileData.StartPlace.Longitude.ToString(), destination.Latitude.ToString(), destination.Longitude.ToString(),
                                                                                  Util.UserProfileData.StartPlace.Address, destination.DisplayName });
                }
            }
            catch (Exception ex)
            {
                Util.HandleMessage("Map direction couldn't be loaded", ex.ToString(), "Error");
            }
        }