public MyMapPage() { InitializeComponent(); var posVancouver = new Xamarin.Forms.Maps.Position(49.25, -123.13); var myPin = new Xamarin.Forms.Maps.Pin() { Label = "Vancouver, BC", Position = posVancouver, Type = PinType.SearchResult //no effect in XM 1.4 }; MyMap.Pins.Add(myPin); myPin.Clicked += (object sender, EventArgs e) => { //not currently working - Xam Forms bug? var pin = sender as Xamarin.Forms.Maps.Pin; if (pin != null) { DisplayAlert("Tapped!", "Pin was tapped.", "OK"); Debug.WriteLine("Pin {0} Clicked!!", pin.Label); } }; //move to location var mapSpan = MapSpan.FromCenterAndRadius(posVancouver, Distance.FromKilometers(2.5)); MyMap.MoveToRegion(mapSpan); }
private void DisplayInMap(List <Post> posts) { foreach (var post in posts) { try { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Type = Xamarin.Forms.Maps.PinType.SavedPin, Position = position, Label = post.VenueName, Address = post.Address, }; LocationMap.Pins.Add(pin); } catch (NullReferenceException) { DisplayAlert("position", "No position is selected: ", "ok"); } catch (Exception ex) { DisplayAlert("Error", ex.Message, "ok"); } } }
protected override async void OnAppearing() { base.OnAppearing(); //if (appMap.IsShowingUser) //{ // this.StartPositioning(); //} this.StartPositioning(); //var notes = await App.Database.GetNotesAsync(); var notes = await App.AzureDb.GetNotesAsync(); foreach (var note in notes) { if (!note.Lat.HasValue || !note.Lng.HasValue) { continue; } var position = new Xamarin.Forms.Maps.Position((double)note.Lat, (double)note.Lng); var pin = new Xamarin.Forms.Maps.Pin() { Type = PinType.SavedPin, Position = position, Label = note.Text, }; appMap.Pins.Add(pin); } }
private void DisplayInMap(List <Post> posts) { foreach (var post in posts) { try { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Type = PinType.SavedPin, Position = position, Label = post.VenueName, Address = post.Address }; LocationsMap.Pins.Add(pin); } catch (NullReferenceException nllEx) { //TODO implement error handling for null exception [DisplayMap] } catch (Exception ex) { //TODO implement error handling for exception [DisplayMap] } } }
// From 11-91 no longer using local SQLite - using Azure cloud db instead // bespoke method to loop through all posts private void DisplayInMap(List <Post> posts) { // throw new NotImplementedException(); // boilerplate foreach (var post in posts) { try { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); // shift map Position to record's lat/lng var pin = new Xamarin.Forms.Maps.Pin() // could have used namespace but this d'illustrate where stuff's from { // initialise the map pin's details / parameters Type = PinType.SavedPin, // type could be SearchResult, Generic &c Position = position, Label = post.VenueName, Address = post.Address }; locationsMap.Pins.Add(pin); } catch (NullReferenceException nre) { } catch (Exception e) { } } }
private void MoveMap(Plugin.Geolocator.Abstractions.Position position) { var Theposition = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude); var Map = new Xamarin.Forms.Maps.MapSpan(Theposition, 1, 1); var pin = new Xamarin.Forms.Maps.Pin() { Type = Xamarin.Forms.Maps.PinType.Place, Position = Theposition, Label = "Traore" }; LocationsMap.MoveToRegion(Map); LocationsMap.Pins.Add(pin); pin.Clicked += async(sender, e) => { await DisplayAlert("Test", "Test", "test"); }; }
private void DisplayInMap(List <Post> posts) { foreach (var post in posts) { try { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Type = Xamarin.Forms.Maps.PinType.SavedPin, Position = position, Label = post.VenueName, Address = post.Address }; locationMap.Pins.Add(pin); } catch (NullReferenceException nre) { Console.Write(nre); } catch (Exception ex) { Console.Write(ex); } } }
protected void SetCustomerLocationPin() { Geocoder geoCoder = new Geocoder(); string xamarinAddress = "91 Oak Glen Dr, Pequea, PA 17565"; //Task<IEnumerable<Position>> geoCoderTask = (geoCoder.GetPositionsForAddressAsync(xamarinAddress)); //geoCoderTask.Wait(); //List<Position> approximateLocations = geoCoderTask.Result.ToList(); //if (approximateLocations.Count < 1) //{ // return; //} _customerLocationPin = new Pin(); _customerLocationPin.Position = new Position(39.909630, -76.299061); //approximateLocations[0]; _customerLocationPin.Label = "Greg Hripto"; // _customer.CustomerName; _customerLocationPin.Address = xamarinAddress; }
public void DisplayInMap() { var spots = DummySpotsData.Read(); foreach (var spot in spots) { try { var position = new Xamarin.Forms.Maps.Position(spot.Latitude, spot.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Type = Xamarin.Forms.Maps.PinType.SavedPin, Position = position, Label = spot.Name }; map.Pins.Add(pin); } catch (NullReferenceException nre) { } catch (Exception ex) { } } }
private void DisplayInMaps() { try { var position = new Xamarin.Forms.Maps.Position(ChosenLocation.Latitude, ChosenLocation.Longitude); var distanceRestrictionInMeters = double.Parse(Settings.DistanceRestriction) * 1000; var pin = new Xamarin.Forms.Maps.Pin { Type = Xamarin.Forms.Maps.PinType.SavedPin, Position = position, Label = "Home", Address = ChosenLocation.Address }; LocationMap.Pins.Add(pin); Circle circle = new Circle { Center = position, Radius = new Distance(distanceRestrictionInMeters), //StrokeColor = Color.FromHex("#88FF0000"), StrokeColor = Color.FromHex("#8800FF00"), StrokeWidth = 4, //FillColor = Color.FromHex("#88FFC0CB") FillColor = Color.FromHex("#88C0FFCB") }; LocationMap.MapElements.Add(circle); } catch (NullReferenceException nre) { } catch (Exception ex) { } }
public void DisplayMap(IList <Post> posts) { try { foreach (var post in posts) { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Position = position, Type = Xamarin.Forms.Maps.PinType.SavedPin, Label = post.VenueName, Address = post.Address }; locationsMap.Pins.Add(pin); } } catch (NullReferenceException nre) { } catch (Exception ex) { DisplayAlert("failed", "Failed to display pins", "OK"); } }
private void DisplayInMaps(List <Post> posts) { foreach (var post in posts) { try { { var position = new Xamarin.Forms.Maps.Position(post.Latitude, post.Longitude); var pin = new Xamarin.Forms.Maps.Pin() { Type = Xamarin.Forms.Maps.PinType.SavedPin, Position = position, Label = post.VenueName, Address = post.Address }; locationsMap.Pins.Add(pin); } } catch (NullReferenceException nre) { DisplayAlert("Error", nre.Message, "Ok"); } }
private void OnGoToDetails(Xamarin.Forms.Maps.Pin pin) { Measurement item = Items.First <Measurement>(i => i.Installation.Address.Description.Equals(pin.Address)); _navigation.PushAsync(new DetailsPage(item)); }
protected async override void OnAppearing() { base.OnAppearing(); try { var request = new GeolocationRequest(GeolocationAccuracy.Best, TimeSpan.FromSeconds(6)); var location = await Geolocation.GetLocationAsync(request); //var location = await Geolocation.GetLastKnownLocationAsync(); Xamarin.Forms.Maps.Position position = new Xamarin.Forms.Maps.Position(location.Latitude, location.Longitude); Xamarin.Forms.Maps.MapSpan mapSpan = new Xamarin.Forms.Maps.MapSpan(position, 0.01, 0.01); Xamarin.Forms.Maps.Map map = new Xamarin.Forms.Maps.Map(mapSpan) { IsShowingUser = true }; Xamarin.Forms.Maps.Pin boardwalkPin = new Xamarin.Forms.Maps.Pin { Label = "U Plaza", Address = "The city with a KhonKean", Type = Xamarin.Forms.Maps.PinType.SearchResult, Position = new Xamarin.Forms.Maps.Position(16.480157, 102.818123) //16.43307340526658, 102.8255601788635 16.480157,102.818123 }; Xamarin.Forms.Maps.Pin boardwalkPin2 = new Xamarin.Forms.Maps.Pin { Label = "โจ๊กเผาหม้อ", Address = "โจ๊กกกกกกกก", Type = Xamarin.Forms.Maps.PinType.SearchResult, Position = new Xamarin.Forms.Maps.Position(16.483848, 102.818624) //16.43307340526658, 102.8255601788635 16.480157,102.818123 }; map.Pins.Add(boardwalkPin); map.Pins.Add(boardwalkPin2); var listpin = new List <Xamarin.Forms.Maps.Pin>(); //var boardwalkPin3 = new List<Xamarin.Forms.Maps.Pin>() { //}; //listpin.Add(boardwalkPin); //boardwalkPin2.MarkerClicked += async (s, args) => //{ // args.HideInfoWindow = true; // string pinName = ((Xamarin.Forms.Maps.Pin)s).Label; // await DisplayAlert("Pin Clicked", $"{pinName} was clicked.", "Ok"); //}; map.MapClicked += async(s, arg) => { var x = arg.Position.Latitude; var y = arg.Position.Longitude; var answer = await this.DisplayAlert("แจ้งเตือน", $"ต้องการMarkใช่หรือไม่", "Yes", "CLOSE"); Debug.WriteLine("Answer: " + answer); //this.DisplayAlert("แจ้งเตือน", $"ต้องการMarkใช่หรือไม่", "Yes", "CLOSE"); if (answer == true) { Xamarin.Forms.Maps.Pin boardwalkPinx = new Xamarin.Forms.Maps.Pin { Label = "โจ๊กเผาหม้อ", Address = "โจ๊กกกกกกกก", Type = Xamarin.Forms.Maps.PinType.SearchResult, Position = new Xamarin.Forms.Maps.Position(x, y), //16.43307340526658, 102.8255601788635 16.480157,102.818123 }; map.Pins.Add(boardwalkPinx); } }; Content = map; //Xamarin.Forms.GoogleMaps.Map map2 = new Xamarin.Forms.GoogleMaps.Map() { //}; //map2.MapLongClicked += (sender, e) => //{ // var lat = e.Point.Latitude.ToString("0.000"); // var lng = e.Point.Longitude.ToString("0.000"); // this.DisplayAlert("MapLongClicked", $"{lat}/{lng}", "CLOSE"); //}; } catch (FeatureNotSupportedException fnsEx) { Console.WriteLine(fnsEx); } catch (FeatureNotEnabledException fneEx) { Console.WriteLine(fneEx); } catch (PermissionException pEx) { Console.WriteLine(pEx); } catch (Exception ex) { Console.WriteLine(ex); } }
bool Equals(Pin other) { return(string.Equals(Label, other.Label) && Equals(Position, other.Position) && Type == other.Type && string.Equals(Address, other.Address)); }
public CustomerMapPageViewModel(Pin customerLocationPin) { // puke _customerLocationPin = customerLocationPin; }
protected async override void OnAppearing() { base.OnAppearing(); try { var request = new GeolocationRequest(GeolocationAccuracy.Best, TimeSpan.FromSeconds(6)); var location = await Geolocation.GetLocationAsync(request); //var location = await Geolocation.GetLastKnownLocationAsync(); Xamarin.Forms.Maps.Position position = new Xamarin.Forms.Maps.Position(location.Latitude, location.Longitude); Xamarin.Forms.Maps.MapSpan mapSpan = new Xamarin.Forms.Maps.MapSpan(position, 0.01, 0.01); Xamarin.Forms.Maps.Map map = new Xamarin.Forms.Maps.Map(mapSpan) { IsShowingUser = true }; var latnow = location.Latitude; var longnow = location.Longitude; reverseGeocodeEntry.Text = location.Latitude + "," + location.Longitude; //< x:Double x:Name = "latnow" ></ x:Double > //< x:Double x:Name = "longnow" ></ x:Double > Xamarin.Forms.Maps.Pin boardwalkPin = new Xamarin.Forms.Maps.Pin { Label = "U Plaza", Address = "The city with a KhonKean", Type = Xamarin.Forms.Maps.PinType.SearchResult, Position = new Xamarin.Forms.Maps.Position(16.480157, 102.818123) //16.43307340526658, 102.8255601788635 16.480157,102.818123 }; Xamarin.Forms.Maps.Pin boardwalkPin2 = new Xamarin.Forms.Maps.Pin { Label = "โจ๊กเผาหม้อ", Address = "โจ๊กกกกกกกก", Type = Xamarin.Forms.Maps.PinType.SearchResult, Position = new Xamarin.Forms.Maps.Position(16.483848, 102.818624) //16.43307340526658, 102.8255601788635 16.480157,102.818123 }; map.Pins.Add(boardwalkPin); map.Pins.Add(boardwalkPin2); Position positionx = new Position(location.Latitude, location.Longitude); map.MoveToRegion(new MapSpan(positionx, 0.1, 0.1)); //this.mapapi = map; Content = map; //map.Pins.Add(new Pin //{ // Label = "Xamarin", // Position = positionx //}); //var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); //Xamarin.Forms.Maps.Pin pin = new Xamarin.Forms.Maps.Pin //{ // Type = PinType.Place, // Position = new Position(16.480157, 102.818123), // Label = "First", // Address = "First", // //Icon = Xamarin.Forms.GoogleMaps.BitmapDescriptorFactory.FromView(new Image() { Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25 }) //}; //map.Pins.Add(pin); } catch (FeatureNotSupportedException fnsEx) { Console.WriteLine(fnsEx); } catch (FeatureNotEnabledException fneEx) { Console.WriteLine(fneEx); } catch (PermissionException pEx) { Console.WriteLine(pEx); } catch (Exception ex) { Console.WriteLine(ex); } }