/// <summary>
        /// Navigate to specific latitude and longitude.
        /// </summary>
        /// <param name="name">Label to display</param>
        /// <param name="latitude">Lat</param>
        /// <param name="longitude">Long</param>
        /// <param name="navigationType">Type of navigation</param>
        public async void NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = string.Empty;
            }

            // Get the values required to specify the destination.
            var driveOrWalk = navigationType == NavigationType.Walking ? "ms-walk-to" : "ms-drive-to";

            // Assemble the Uri to launch.
            var uri = new Uri(driveOrWalk + ":?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) +
                              "&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture) + "&destination.name=" + name);

            // Launch the Uri.
            var success = await Windows.System.Launcher.LaunchUriAsync(uri);

            if (success)
            {
                return;
            }


            var mapsDirectionsTask = new MapsDirectionsTask();


            // You can specify a label and a geocoordinate for the end point.
            var location = new GeoCoordinate(latitude, longitude);
            var lml      = new LabeledMapLocation(name, location);

            mapsDirectionsTask.End = lml;

            mapsDirectionsTask.Show();
        }
Example #2
0
        public void getDirections(string options)
        {
            GetDirectionsOptions directionOptions = JSON.JsonHelper.Deserialize <GetDirectionsOptions>(options);

            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();

            // You can specify a label and a geocoordinate for the end point.
            if (directionOptions.Start != null)
            {
                LabeledMapLocation startLML = new LabeledMapLocation();
                startLML.Location = new GeoCoordinate(directionOptions.Start.Coordinates.Latitude, directionOptions.Start.Coordinates.Longitude);
                if (directionOptions.Start.Label != null)
                {
                    startLML.Label = directionOptions.Start.Label;
                }
                bingMapsDirectionsTask.Start = startLML;
            }
            // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
            if (directionOptions.End != null)
            {
                LabeledMapLocation endLML = new LabeledMapLocation();
                if (directionOptions.End.Coordinates != null)
                {
                    endLML.Location = new GeoCoordinate(directionOptions.End.Coordinates.Latitude, directionOptions.End.Coordinates.Longitude);
                }
                if (directionOptions.End.Label != null)
                {
                    endLML.Label = directionOptions.End.Label;
                }
                bingMapsDirectionsTask.End = endLML;
            }

            // If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
            bingMapsDirectionsTask.Show();
        }
Example #3
0
        private void directionTask_Click(object sender, EventArgs e)
        {
            LabeledMapLocation start = null;
            LabeledMapLocation end   = null;

            if (!string.IsNullOrEmpty(departureTerm.Text))
            {
                start = new LabeledMapLocation {
                    Label = departureTerm.Text
                }
            }
            ;

            if (!string.IsNullOrEmpty(destinationTerm.Text))
            {
                end = new LabeledMapLocation {
                    Label = destinationTerm.Text
                }
            }
            ;

            if (start == null && end == null)
            {
                MessageBox.Show("Please enter start and/or end locations.");
                return;
            }

            var task = new BingMapsDirectionsTask {
                Start = start, End = end
            };

            task.Show();
        }
    }
}
Example #4
0
        private void Accept_Click(object sender, RoutedEventArgs e)
        {
            GeoCoordinate spaceNeedleLocation = new GeoCoordinate(thislocation.Latitude, thislocation.Longitude);


            XElement doctorID  = new XElement("doctorID", "xiaoming");
            XElement latitude  = new XElement("latitude", thislocation.Latitude);
            XElement longitude = new XElement("longitude", thislocation.Longitude);
            XElement confirm   = new XElement("confirm", "true");

            accept_Info = new XDocument(new XElement("EmergencyConfirm", doctorID, latitude, longitude, confirm));


            callREST();

            try
            {
                LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("Patient Location", spaceNeedleLocation);

                bingMapsDirectionsTask.End = spaceNeedleLML;

                bingMapsDirectionsTask.Show();
            }
            catch (WebException) {
            }

            //this.NavigationService.Navigate(new Uri("/ShowRoute.xaml", UriKind.Relative));
        }
Example #5
0
        private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        {
            if (e.Position.Location.IsUnknown)
            {
                MessageBox.Show("Please wait while your prosition is determined");
                return;
            }

            if (_needDirections)
            {
                BingMapsDirectionsTask Direction = new BingMapsDirectionsTask();
                LabeledMapLocation start = new LabeledMapLocation("Current Location", new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude));
                LabeledMapLocation End = new LabeledMapLocation(dateViewModel.Date.Venue.Name, new GeoCoordinate(dateViewModel.Date.Venue.Latitude, dateViewModel.Date.Venue.Longitude));
                Direction.Start = start;
                Direction.End = End;

                _watcher.Stop();
                Direction.Show();
            }
            else
            {
                BingMapsTask bingMapsTask = new BingMapsTask();
                LabeledMapLocation currentLocation = new LabeledMapLocation("Current Location", new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude));

                bingMapsTask.ZoomLevel = 10;
                bingMapsTask.Center = currentLocation.Location;
                _watcher.Stop();
                bingMapsTask.Show();
            }
        } 
Example #6
0
        /// <summary>
        /// Event handler for the directions button
        /// </summary>
        /// <param name="sender">Sender of the event</param>
        /// <param name="e">Event arguments</param>
        private void OnDirectionsClick(object sender, EventArgs e)
        {
            try
            {
                this.UserLocationMarker.GeoCoordinate = Globals.RecentLocation.Coordinate;
                if (this.RouteDirectionsPushPin == null || this.RouteDirectionsPushPin.GeoCoordinate == null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.MapTapHoldToGetDirections, "basicWrap", "Info!"));
                }
                else
                {
                    GeoCoordinate          spaceNeedleLocation = new GeoCoordinate(this.UserLocationMarker.GeoCoordinate.Latitude, this.UserLocationMarker.GeoCoordinate.Longitude);
                    BingMapsDirectionsTask bmDirectionTask     = new BingMapsDirectionsTask();
                    LabeledMapLocation     currentLML          = new LabeledMapLocation("Current location", spaceNeedleLocation);
                    bmDirectionTask.Start = currentLML;


                    GeoCoordinate      destinationLocation    = new GeoCoordinate(this.RouteDirectionsPushPin.GeoCoordinate.Latitude, this.RouteDirectionsPushPin.GeoCoordinate.Longitude);
                    LabeledMapLocation destinationLocationLML = new LabeledMapLocation("Destination location", destinationLocation);
                    bmDirectionTask.End = destinationLocationLML;

                    bmDirectionTask.Show();
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.ShowExceptionMessageAndLog(exception, true);
            }
        }
        /// <summary>
        /// Shows the Maps application with driving directions displayed for the specified ending location.
        /// </summary>
        /// <param name="endingLocation">The ending location for which driving directions are displayed.</param>
        /// <exception cref="InvalidOperationException">Start and End cannot both be invalid.</exception>
        public void Show(LabeledMapLocation endingLocation)
        {
#if WP8
            Show(null, endingLocation);
#else
            throw new NotSupportedException("This service is not supported in Windows Phone 7.x. Use the BingMapsService instead.");
#endif
        }
 /// <summary>
 /// Shows the Bing Maps application with driving directions displayed for the specified starting and ending locations.
 /// </summary>
 /// <param name="startingLocation">The starting location for which driving directions are displayed.</param>
 /// <param name="endingLocation">The ending location for which driving directions are displayed.</param>
 /// <exception cref="InvalidOperationException">Start and End cannot both be invalid.</exception>
 public void Show(LabeledMapLocation startingLocation, LabeledMapLocation endingLocation)
 {
     new BingMapsDirectionsTask()
     {
         Start = startingLocation,
         End   = endingLocation
     }.Show();
 }
Example #9
0
        void GotoLocation(double lat, double lng, String name)
        {
            MapsDirectionsTask mdt         = new MapsDirectionsTask();
            GeoCoordinate      gpsLocation = new GeoCoordinate(lat, lng);
            LabeledMapLocation mapLocation = new LabeledMapLocation(name, gpsLocation);

            mdt.End = mapLocation;
            mdt.Show();
        }
Example #10
0
        // Click directions appbar button
        private void abDirections_Click(object sender, EventArgs e)
        {
            // Windows Phone Task to show directions
            BingMapsDirectionsTask bmdTask = new BingMapsDirectionsTask();
            LabeledMapLocation destinationLocation = new LabeledMapLocation("End", destination);
            LabeledMapLocation startLocation = new LabeledMapLocation("Start", departure);

            bmdTask.Start = startLocation;  // Start location is current user's location
            bmdTask.End = destinationLocation;  // Destination location is location that was shared with the current user
            bmdTask.Show(); // Show directions
        }
Example #11
0
        /// <summary>
        /// to display distance b/w selected location from current location on map.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbkDistance_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var selectedCategory = (this.DataContext as CityData);
            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
            LabeledMapLocation     start = new LabeledMapLocation();
            LabeledMapLocation     end   = new LabeledMapLocation(selectedCategory.Address, new GeoCoordinate(selectedCategory.Coordinate.Latitude, selectedCategory.Coordinate.Longitude));

            bingMapsDirectionsTask.Start = start;
            bingMapsDirectionsTask.End   = end;
            bingMapsDirectionsTask.Show();
        }
Example #12
0
        public void LaunchNavigationAsync(NavigationModel navigationModel)
        {
            var mapsDirectionsTask = new MapsDirectionsTask();

            var destinationGeolocation = new GeoCoordinate(navigationModel.Latitude, navigationModel.Longitude);
            var destinationMapLocation = new LabeledMapLocation(navigationModel.DestinationName, destinationGeolocation);

            mapsDirectionsTask.End = destinationMapLocation;

            mapsDirectionsTask.Show();
        }
        /// <summary>
        /// Shows the Maps application with driving directions displayed for the specified starting and ending locations.
        /// </summary>
        /// <param name="startingLocation">The starting location for which driving directions are displayed.</param>
        /// <param name="endingLocation">The ending location for which driving directions are displayed.</param>
        /// <exception cref="InvalidOperationException">Start and End cannot both be invalid.</exception>
        public void Show(LabeledMapLocation startingLocation, LabeledMapLocation endingLocation)
        {
#if WP8
            new MapsDirectionsTask()
            {
                Start = startingLocation,
                End   = endingLocation
            }.Show();
#else
            throw new NotSupportedException("This service is not supported in Windows Phone 7.x. Use the BingMapsService instead.");
#endif
        }
Example #14
0
        /// <summary>
        /// Shows the Maps application with driving directions displayed for the specified starting and ending locations.
        /// </summary>
        /// <param name="startingLocation">The starting location for which driving directions are displayed.</param>
        /// <param name="endingLocation">The ending location for which driving directions are displayed.</param>
        /// <exception cref="InvalidOperationException">Start and End cannot both be invalid.</exception>
        public void Show(LabeledMapLocation startingLocation, LabeledMapLocation endingLocation)
        {
#if WP8
            new MapsDirectionsTask()
#else
            new BingMapsDirectionsTask()
#endif
            {
                Start = startingLocation,
                End   = endingLocation
            }.Show();
        }
Example #15
0
        /// <summary>
        /// Navigate to an address
        /// </summary>
        /// <param name="name">Label to display</param>
        /// <param name="street">Street</param>
        /// <param name="city">City</param>
        /// <param name="state">Sate</param>
        /// <param name="zip">Zip</param>
        /// <param name="country">Country</param>
        /// <param name="countryCode">Country Code if applicable</param>
        /// <param name="navigationType">Navigation type</param>
        public Task <bool> NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = string.Empty;
                }

                if (string.IsNullOrWhiteSpace(street))
                {
                    street = string.Empty;
                }

                if (string.IsNullOrWhiteSpace(city))
                {
                    city = string.Empty;
                }

                if (string.IsNullOrWhiteSpace(state))
                {
                    state = string.Empty;
                }

                if (string.IsNullOrWhiteSpace(zip))
                {
                    zip = string.Empty;
                }

                if (string.IsNullOrWhiteSpace(country))
                {
                    country = string.Empty;
                }

                var mapsDirectionsTask = new MapsDirectionsTask();


                // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
                var lml = new LabeledMapLocation(string.Format("{0}%20{1},%20{2}%20{3}%20{4}", street, city, state, zip, country), null);

                mapsDirectionsTask.End = lml;

                // If mapsDirectionsTask.Start is not set, the user's current location is used as the start point.

                mapsDirectionsTask.Show();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to launch maps: " + ex);
                return(Task.FromResult(false));
            }
            return(Task.FromResult(true));
        }
        private void Route_Click(object sender, EventArgs e)
        {
            MapsDirectionsTask direction = new MapsDirectionsTask();

            LabeledMapLocation startLabeled = new LabeledMapLocation("Ваше местоположение", App.PlaceInfoViewModel.UserLocation);

            direction.Start = startLabeled;

            LabeledMapLocation endLabeled = new LabeledMapLocation(App.PlaceInfoViewModel.PlaceInfo.Name, App.PlaceInfoViewModel.PlaceLocation);

            direction.End = endLabeled;

            direction.Show();
        }
        private void Route_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            MapsDirectionsTask direction = new MapsDirectionsTask();

            LabeledMapLocation startLabeled = new LabeledMapLocation("Ваше местоположение", App.ResultPageViewModel.UserGeoCoordinate);

            direction.Start = startLabeled;

            LabeledMapLocation endLabeled = new LabeledMapLocation(App.ResultPageViewModel.SelectPlace.Name, new GeoCoordinate(App.ResultPageViewModel.SelectPlace.Geometry.Location.Lat, App.ResultPageViewModel.SelectPlace.Geometry.Location.Lng));

            direction.End = endLabeled;

            direction.Show();
        }
Example #18
0
        private async void btnDirection_Click(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate(new Uri("/View/Exhibiton/Direction.xaml?start=" + senderAddress.Text+"&end="+receiveAddress.Text, UriKind.Relative));
            MapsDirectionsTask mapsDic = new MapsDirectionsTask();
            LabeledMapLocation start   = new LabeledMapLocation();

            start.Label = senderAddress.Text;
            LabeledMapLocation end = new LabeledMapLocation();

            end.Label     = receiveAddress.Text;
            mapsDic.Start = start; // điểm bắt đầu
            mapsDic.End   = end;   // điểm kết thúc
            mapsDic.Show();
        }
Example #19
0
        private void txtDescription_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();

            LabeledMapLocation start = new LabeledMapLocation("My Location", new GeoCoordinate(Convert.ToDouble(NavigationContext.QueryString["lat1"]), Convert.ToDouble(NavigationContext.QueryString["lon1"])));

            bingMapsDirectionsTask.Start = start;

            LabeledMapLocation end = new LabeledMapLocation(NavigationContext.QueryString["name"], new GeoCoordinate(Convert.ToDouble(NavigationContext.QueryString["lat2"]), Convert.ToDouble(NavigationContext.QueryString["lon2"])));

            bingMapsDirectionsTask.End = end;

            bingMapsDirectionsTask.Show();
        }
 private void Direction_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     Debug.WriteLine("wasssup !!!!!!");
     if (!isolatedStorage.Contains("long") || ((String)(isolatedStorage["long"])).Equals(""))
     {
         MessageBox.Show("Please add your car location.");
     }
     else
     {
         GeoCoordinate          spaceNeedleLocation    = new GeoCoordinate(Double.Parse((String)(isolatedStorage["lat"])), Double.Parse((String)(isolatedStorage["long"])));
         BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
         LabeledMapLocation     spaceNeedleLML         = new LabeledMapLocation("Your car", spaceNeedleLocation);
         bingMapsDirectionsTask.End = spaceNeedleLML;
         bingMapsDirectionsTask.Show();
     }
 }
Example #21
0
 void ContactSearch_Completed(object sender, AddressResult e)
 {
     try
     {
         if (e.TaskResult == TaskResult.OK)
         {
             BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
             LabeledMapLocation     endLabeledMapLocation  = new LabeledMapLocation(e.Address, null);
             bingMapsDirectionsTask.End = endLabeledMapLocation;
             bingMapsDirectionsTask.Show();
         }
     }
     catch (Exception x)
     {
         Debug.WriteLine("Contact Search Error: " + x.ToString());
         MessageBox.Show("Malformed address");
     }
 }
 private void RouteToCar()
 {
     if (IsolatedStorageSettings.ApplicationSettings.Contains("car"))
     {
         Car car = (Car)IsolatedStorageSettings.ApplicationSettings["car"];
         MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask();
         LabeledMapLocation carMapLocation     = new LabeledMapLocation("Ma voiture", car.Geo);
         mapsDirectionsTask.End = carMapLocation;
         mapsDirectionsTask.Show();
     }
     else
     {
         this.OnUiThread(() =>
         {
             MessageBox.Show("Vous devez d'abord sauvegarder la position de votre voiture.");
         });
     }
 }
        /// <summary>
        /// Navigate to an address
        /// </summary>
        /// <param name="name">Label to display</param>
        /// <param name="street">Street</param>
        /// <param name="city">City</param>
        /// <param name="state">Sate</param>
        /// <param name="zip">Zip</param>
        /// <param name="country">Country</param>
        /// <param name="countryCode">Country Code if applicable</param>
        /// <param name="navigationType">Navigation type</param>
        public void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(street))
            {
                street = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(city))
            {
                city = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(state))
            {
                state = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(zip))
            {
                zip = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(country))
            {
                country = string.Empty;
            }

            var mapsDirectionsTask = new MapsDirectionsTask();


            // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
            var lml = new LabeledMapLocation(string.Format("{0}%20{1},%20{2}%20{3}%20{4}", street, city, state, zip, country), null);

            mapsDirectionsTask.End = lml;

            // If mapsDirectionsTask.Start is not set, the user's current location is used as the start point.

            mapsDirectionsTask.Show();
        }
Example #24
0
        public void getDirections(string options)
        {
            string[] args       = JsonHelper.Deserialize <string[]>(options);
            string   callbackId = args[1];

            GetDirectionsOptions directionOptions = JsonHelper.Deserialize <GetDirectionsOptions>(args[0]);

            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();

            // You can specify a label and a geocoordinate for the end point.
            if (directionOptions.Start != null)
            {
                LabeledMapLocation startLML = new LabeledMapLocation();
                if (directionOptions.Start.Coordinates != null)
                {
                    startLML.Location = new GeoCoordinate(directionOptions.Start.Coordinates.Latitude, directionOptions.Start.Coordinates.Longitude);
                }
                if (directionOptions.Start.Label != null)
                {
                    startLML.Label = directionOptions.Start.Label;
                }
                bingMapsDirectionsTask.Start = startLML;
            }
            // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
            if (directionOptions.End != null)
            {
                LabeledMapLocation endLML = new LabeledMapLocation();
                if (directionOptions.End.Coordinates != null)
                {
                    endLML.Location = new GeoCoordinate(directionOptions.End.Coordinates.Latitude, directionOptions.End.Coordinates.Longitude);
                }
                if (directionOptions.End.Label != null)
                {
                    endLML.Label = directionOptions.End.Label;
                }
                bingMapsDirectionsTask.End = endLML;
            }

            // If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
            bingMapsDirectionsTask.Show();
            DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
        }
Example #25
0
        /// <summary>
        /// Event handler for the directions button
        /// </summary>
        /// <param name="sender">Sender of the event</param>
        /// <param name="e">Event arguments</param>
        private void OnDirections(object sender, EventArgs e)
        {
            if (this.RouteDirectionsPushPin.GeoCoordinate == null || this.RouteDirectionsPushPin.Visibility == Visibility.Collapsed)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.MapTapHoldToGetDirections, "basicWrap", "Info!"));
            }
            else
            {
                GeoCoordinate          spaceNeedleLocation = new GeoCoordinate(this.UserLocationMarker.GeoCoordinate.Latitude, this.UserLocationMarker.GeoCoordinate.Longitude);
                BingMapsDirectionsTask bmDirectionTask     = new BingMapsDirectionsTask();
                LabeledMapLocation     currentLML          = new LabeledMapLocation("Current location", spaceNeedleLocation);
                bmDirectionTask.Start = currentLML;


                GeoCoordinate      destinationLocation    = new GeoCoordinate(this.RouteDirectionsPushPin.GeoCoordinate.Latitude, this.RouteDirectionsPushPin.GeoCoordinate.Longitude);
                LabeledMapLocation destinationLocationLML = new LabeledMapLocation("Destination location", destinationLocation);
                bmDirectionTask.End = destinationLocationLML;

                bmDirectionTask.Show();
            }
        }
 /// <summary>
 /// Shows the Bing Maps application with driving directions displayed for the specified ending location.
 /// </summary>
 /// <param name="endingLocation">The ending location for which driving directions are displayed.</param>
 /// <exception cref="InvalidOperationException">Start and End cannot both be invalid.</exception>
 public void Show(LabeledMapLocation endingLocation)
 {
     Show(null, endingLocation);
 }