//##################################### Pivot View 5 Close to you ##########################################// private async void mapLocations() { List <Models.HealthFacility> healthFacilitties = db.getAllHospitals(); var locator = new Geolocator(); locator.DesiredAccuracyInMeters = 5; #if (DEVICE) /* REAL DEVICE */ var devicePosition = await locator.GetGeopositionAsync(); await MainMap.TrySetViewAsync(devicePosition.Coordinate.Point, 12D); #else ///*TEMPORARY FOR DEBUGGING*/ /// DUMMY DEVICE var debugPosition = new BasicGeoposition(); debugPosition.Latitude = 42.642791; debugPosition.Longitude = 23.338603; var debugPoint = new Geopoint(debugPosition); ////##################################################### #endif Position Start, End; #if (DEVICE) /* REAL DEVICE COORDS */ Start.Latitude = devicePosition.Coordinate.Point.Position.Latitude; Start.Longitude = devicePosition.Coordinate.Point.Position.Longitude; #else /* DUMMY DEVICE COORDS */ Start.Latitude = 42.642791; Start.Longitude = 23.338603; #endif for (int i = 0; i < healthFacilitties.Count; i++) { End.Latitude = healthFacilitties[i].latitude; End.Longitude = healthFacilitties[i].longitude; healthFacilitties[i].distance = Distance(Start, End); healthFacilitties[i].hospital_name = healthFacilitties[i].hospital_name + " - " + healthFacilitties[i].distance.ToString("0.0") + " km"; } healthFacilitties = healthFacilitties.OrderBy(x => x.distance).ToList(); Hospitals.ItemsSource = healthFacilitties; #if (DEVICE) /* REAL DEVICE */ //await MainMap.TrySetViewAsync(devicePosition.Coordinate.Point, 12D); #else /* DUMMY DEVICE */ await MainMap.TrySetViewAsync(debugPoint, 12D); #endif var pin = new MapIcon() { #if (DEVICE) /* REAL DEVICE */ Location = devicePosition.Coordinate.Point, #else /* DUMMY DEVICE */ Location = debugPoint, #endif Title = "I am here", Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Pictures/pin.png")), NormalizedAnchorPoint = new Point() { X = 0.32, Y = 0.78 }, }; MainMap.MapElements.Add(pin); for (int i = 0; i < db.getAllHospitals().Count; i++) { var currHospitalPos = new BasicGeoposition(); currHospitalPos.Latitude = db.getAllHospitals()[i].latitude; currHospitalPos.Longitude = db.getAllHospitals()[i].longitude; var hospitalLocationPoint = new Geopoint(currHospitalPos); var hostpital = new MapIcon() { Location = hospitalLocationPoint, Title = db.getAllHospitals()[i].hospital_name, Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Pictures/hospital_pin.png")), NormalizedAnchorPoint = new Point() { X = 0.32, Y = 0.78 }, }; MainMap.MapElements.Add(hostpital); } }