public WalkDistancePage() { InitializeComponent(); this.Title = "Distance Travelled Information"; this.BindingContext = new WalkDistancePageViewModel(DependencyService.Get <INavigationService>()); origPosition = _viewModel.GetCurrentLocation(); _viewModel.CoordsChanged += Location_CoordsChanged; _viewModel.OnStartUpdate(); customMap = new CustomMapOverlay { MapType = MapType.Street }; customMap.Pins.Clear(); CreatePinPlaceholder(PinType.Place, origPosition.Result.Latitude, origPosition.Result.Longitude, "", "My Location", 1); CreatePinPlaceholder(PinType.Place, _viewModel.Latitude, _viewModel.Longitude, _viewModel.Title, "Difficulty: " + _viewModel.Difficulty + "Total Distance: " + _viewModel.Distance, 2); customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position( origPosition.Result.Latitude, origPosition.Result.Longitude)); customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position( _viewModel.Latitude, _viewModel.Longitude)); customMap.MoveToRegion(MapSpan.FromCenterAndRadius( new Xamarin.Forms.Maps.Position( origPosition.Result.Latitude, origPosition.Result.Longitude), Distance.FromKilometers(1))); Content = customMap; // create a region around of 1 kilometer customMap.MoveToRegion( MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(_viewModel.Latitude, _viewModel.Longitude), Distance.FromKilometers(1.0)) ); }
public WalkDistancePage() { InitializeComponent(); // Create an instance to our TwitterWebService class //TwitterObject = new TwitterWebService(TwitterAuthDetails.ConsumerKey, //TwitterAuthDetails.ConsumerSecret, //TwitterAuthDetails.AuthToken, TwitterAuthDetails.AuthTokenSecret); TwitterObject = new TwitterWebService(); // Update the Title and Initialise our BindingContext for the Page Title = "Distance Travelled Information"; this.BindingContext = new WalkDistancePageViewModel(DependencyService.Get <INavigationService>()); // Get the current GPS location coordinates and listen for updates origPosition = _viewModel.GetCurrentLocation(); _viewModel.CoordsChanged += Location_PositionChanged; _viewModel.OnStartUpdate(); // Instantiate our Custom Map Overlay customMap = new CustomMapOverlay { MapType = MapType.Street }; // Clear all previously created Pins on our CustomMap customMap.Pins.Clear(); // Create the Pin placeholder that will represent our current location CreatePinPlaceholder(PinType.Place, origPosition.Result.Latitude, origPosition.Result.Longitude, "", "My Location", 1); // Create the Pin placeholder that will represent our ending location CreatePinPlaceholder(PinType.Place, _viewModel.Latitude, _viewModel.Longitude, _viewModel.Title, "Difficulty: " + _viewModel.Difficulty + " Total Distance: " + _viewModel.Distance, 2); // Add the Starting and Ending Latitude and Longitude Coordinates customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position(origPosition.Result.Latitude, origPosition.Result.Longitude)); customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position(_viewModel.Latitude, _viewModel.Longitude)); // Create and Initialise a map region within a one-kilometre radius customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(origPosition.Result.Latitude, origPosition.Result.Longitude), Distance.FromKilometers(1))); // Display our Custom Map for the detected device Platform Content = customMap; }
public WalkDistancePage() { InitializeComponent(); // Create an instance to our TwitterWebService class TwitterObject = new TwitterWebService(); // Update the Title and Initialise our BindingContext for the Page Title = "Distance Travelled Information"; this.BindingContext = new WalkDistancePageViewModel(DependencyService.Get <INavigationService>()); #region using defaultmap/oldmap implementation // Create a pin placeholder within the map containing the // walk information //customMap.Pins.Add(new Pin //{ // Type = PinType.Place, // Position = new Position(_viewModel.Latitude, _viewModel.Longitude), // Label = _viewModel.Title, // Address = "Difficulty: " + _viewModel.Difficulty + " Total Distance: " + _viewModel.Distance, // MarkerId = _viewModel.Title //}); // Create a region around the map within a one-kilometer radius //customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new //Position(_viewModel.Latitude, _viewModel.Longitude), //Distance.FromKilometers(1.0))); #endregion // Get the current GPS location coordinates and listen // for updates origPosition = _viewModel.GetCurrentLocation(); _viewModel.CoordsChanged += Location_CoordsChanged; _viewModel.OnStartUpdate(); // Instantiate our Custom Map Overlay customMap = new CustomMapOverlay { MapType = MapType.Street }; // Clear all previously created Pins on our CustomMap customMap.Pins.Clear(); // Create the Pin placeholder that will represent our // current location CreatePinPlaceholder(PinType.Place, origPosition.Result.Latitude, origPosition.Result.Longitude, "", "My Location", 1); // Create the Pin placeholder that will represent our // ending location CreatePinPlaceholder(PinType.Place, _viewModel.Latitude, _viewModel.Longitude, _viewModel.Title, "Difficulty: " + _viewModel.Difficulty + " Total Distance: " + _viewModel.Distance, 2); // Add the Starting and Ending Latitude and Longitude // Coordinates customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position( origPosition.Result.Latitude, origPosition.Result.Longitude)); customMap.RouteCoordinates.Add(new Xamarin.Forms.Maps.Position( _viewModel.Latitude, _viewModel.Longitude)); // Create and Initialise a map region within a // one-kilometre radius customMap.MoveToRegion(MapSpan.FromCenterAndRadius( new Xamarin.Forms.Maps.Position( origPosition.Result.Latitude, origPosition.Result.Longitude), Distance.FromKilometers(1))); // Display our Custom Map for the detected device // Platform Content = customMap; }