void InitializePinsFromDb() { foreach (Model.Pin p in repo.GetAllPins()) { Meeting meeting = new Meeting(); foreach (Meeting m in repo.GetAllMeetings()) { if (m.Pin_Id == p.Id) { meeting = m; string path = "Assets"; var assembly = typeof(MainPage).GetTypeInfo().Assembly; var stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{path}.{p.Icon}"); Xamarin.Forms.GoogleMaps.Pin newPin = new Xamarin.Forms.GoogleMaps.Pin() { Type = PinType.Place, Label = meeting.ActivityName, Address = "Show more", Position = new Position(p.Latitude, p.Longitude), Icon = BitmapDescriptorFactory.FromStream(stream, id: p.Icon) }; map.Pins.Add(newPin); newPin.Clicked += (sender_pin, e_pin) => { PopupNavigation.PushAsync(new ShowMeetingPopupPage(newPin, map)); }; } } } }
void DrawRoute(List <Xamarin.Forms.GoogleMaps.Position> list) { map.Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); polyline.StrokeColor = Color.Black; polyline.StrokeWidth = 3; foreach (var p in list) { polyline.Positions.Add(p); } map.Polylines.Add(polyline); map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f))); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.SearchResult, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "Pin", Address = "Pin", Tag = "CirclePoint", Icon = (Device.RuntimePlatform == Device.Android)?BitmapDescriptorFactory.FromBundle("ic_circle_point.png") : BitmapDescriptorFactory.FromView(new Image() { Source = "ic_circle_point.png", WidthRequest = 25, HeightRequest = 25 }) }; map.Pins.Add(pin); }
private static void CurrentLocationPropertyChanged(BindableObject bindable, object oldValue, object newValue) { if (newValue == null) { return; } Location location = newValue as Location; CustomMap targetControl = (CustomMap)bindable; var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(location.Latitude, location.Longitude), Label = "Current", Address = "Location", Tag = string.Empty }; if (targetControl.Pins.Count != 0) { targetControl.Pins[0] = pin; } else { targetControl.Pins.Add(pin); } targetControl.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(location.Latitude, location.Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.3))); }
void OnMapClicked(object sender, MapClickedEventArgs e) { var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.SavedPin, Label = "Trash", Position = e.Point, Icon = Xamarin.Forms.GoogleMaps.BitmapDescriptorFactory.DefaultMarker(Color.BlanchedAlmond) }; if (Model.trashbool) { System.Diagnostics.Debug.WriteLine($"MapClick: {e.Point.Latitude}, {e.Point.Longitude}"); map.Pins.Add(pin); //App.database.UpdateItem<Bin>(new Bin { colorID=0, isFull="empty", lat= e.Point.Latitude , longit= e.Point.Longitude}).Wait(); } }
void CalculateDistance(List <Xamarin.Forms.GoogleMaps.Position> list) { map.Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); foreach (var p in list) { polyline.Positions.Add(p); } map.Polylines.Add(polyline); var position = new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude); map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f))); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "Start and ", Address = "running", Tag = string.Empty, Icon = (Device.RuntimePlatform == Device.iOS) ? BitmapDescriptorFactory.FromView(new Image() { Source = "car.png", WidthRequest = 25, HeightRequest = 25 }) : BitmapDescriptorFactory.DefaultMarker(Color.Purple) }; map.Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = "Target", Address = "Place", Tag = string.Empty }; map.Pins.Add(pin1); }
void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { searchLayout.IsVisible = false; stopRouteButton.IsVisible = true; map.Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); foreach (var p in list) { polyline.Positions.Add(p); } map.Polylines.Add(polyline); map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f))); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "First", Address = "First", Tag = string.Empty, Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25 }) }; map.Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = "Last", Address = "Last", Tag = string.Empty }; map.Pins.Add(pin1); }
void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { OnCalculate?.Invoke(this, default(EventArgs)); Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); foreach (var p in list) { polyline.Positions.Add(p); } Polylines.Add(polyline); MoveToRegion(MapSpan.FromCenterAndRadius(new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f))); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "First", Address = "First", Tag = string.Empty, Icon = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_taxi.png") : BitmapDescriptorFactory.FromView(new Image() { Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25 }) }; Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = "Last", Address = "Last", Tag = string.Empty }; Pins.Add(pin1); }
public SuddnMap() {//tae InitializeComponent(); // Xamarin.FormsGoogleMaps.Init("AIzaSyC-vMol82Gj9OVkewE09ADdKMhduW77qgo"); //initialize the map -ios. //var map = new Map( //MapSpan.FromCenterAndRadius( ////new Position(14.55, 121.0244), Distance.FromMiles(0.3))) var position = new Xamarin.Forms.GoogleMaps.Position(14.5599303, 121.0135896); ////var map = new Map() //{ // // IsShowingUser = true, // HeightRequest = 100, // WidthRequest = 960, // VerticalOptions = LayoutOptions.FillAndExpand //}; var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = Xamarin.Forms.GoogleMaps.PinType.Place, Position = position, Label = "my position" }; //gMap.MapType = Xamarin.Forms.GoogleMaps.MapType.Street; //gMap.Pins.Add(pin); //gMap.MoveToRegion(Xamarin.Forms.GoogleMaps.MapSpan.FromCenterAndRadius(position, Xamarin.Forms.GoogleMaps.Distance.FromMiles(1))); //var stack = new StackLayout { Spacing = 0 }; //stack.Children.Add(gMap); //Content = stack; //map.MapType == MapType.Street; }
private void OnTappedTitulo(object sender, EventArgs e) { Label lblClicked = (Label)sender; var item = (TapGestureRecognizer)lblClicked.GestureRecognizers[0]; var latlong = item.CommandParameter; string[] coordenadas = latlong.ToString().Split('|'); double lat = Convert.ToDouble(coordenadas[0]); double lng = Convert.ToDouble(coordenadas[1]); Pin pin = new Pin { Position = new Position(lat, lng), Label = coordenadas[2], Type = PinType.Place //, //Icon = BitmapDescriptorFactory.FromBundle(coordenadas[3]) }; MyMap.Pins.Add(pin); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lng), Distance.FromMeters(5000))); //await Browser.OpenAsync(url.ToString(), BrowserLaunchMode.SystemPreferred); }
void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { mapn.Polylines.Clear(); Polygon polygon = Getpolygondata(); mapn.Polygons.Add(polygon); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); polyline.StrokeColor = Color.Blue; polyline.StrokeWidth = polyline.StrokeWidth * 4; var polylineinside = new Xamarin.Forms.GoogleMaps.Polyline(); polylineinside.StrokeColor = Color.Red; polylineinside.StrokeWidth = polyline.StrokeWidth * 2; foreach (var p in list) { polyline.Positions.Add(p); if (Contains(p, polygon)) { // point is inside polygon polylineinside.Positions.Add(p); } } mapn.Polylines.Add(polyline); if (polylineinside.Positions.Count > 2) { mapn.Polylines.Add(polylineinside); } var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = vm.StartLabel, Address = vm.StartAdd, Tag = "First Point", Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_location.png", WidthRequest = 25, HeightRequest = 25 }) }; mapn.Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = vm.EndLabel, Address = vm.EndAdd, Tag = "Last Point", Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_location_red.png", WidthRequest = 25, HeightRequest = 25 }) }; mapn.Pins.Add(pin1); int InnerDist = 0; if (polylineinside.Positions.Count > 2) { var googleDirection = (vm.GetDistance(polylineinside.Positions.First(), polylineinside.Positions.Last()).Result); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { InnerDist = googleDirection.Routes.FirstOrDefault().Legs.FirstOrDefault().Distance.Value; } } int TotalDistance = vm.CurrentGoogleDirection.Routes.FirstOrDefault().Legs.FirstOrDefault().Distance.Value; decimal TotalFare = 0; decimal DistanceUnit = 0; decimal InnerDistanceUnit = 0; decimal OuterDistanceUnit = 0; int OuterDist = TotalDistance - InnerDist; decimal InnerFare = (Constants.InnerFareRate / (Constants.DistanceUnitKM / Constants.BillingUnit)); decimal OuterFare = (Constants.OuterFareRate / (Constants.DistanceUnitKM / Constants.BillingUnit)); if (InnerDist > 0) { InnerDistanceUnit = (Convert.ToDecimal(InnerDist) / Constants.BillingUnit); OuterDistanceUnit = (Convert.ToDecimal(OuterDist) / Constants.BillingUnit); TotalFare = (InnerFare * InnerDistanceUnit) + (OuterFare * OuterDistanceUnit); DistanceUnit = InnerDistanceUnit + OuterDistanceUnit; } else { DistanceUnit = (TotalDistance / Constants.BillingUnit); TotalFare = (OuterFare * DistanceUnit); } mapn.MoveToRegion(MapSpan.FromPositions(list)); App.Current.MainPage.DisplayAlert("Price", "Total Distance : " + TotalDistance + " & Total Price : " + TotalFare.ToString("F2") + "\nOuter Distance : " + OuterDist + " @ Price : " + Constants.OuterFareRate + " cents" + "\nInner Distance : " + InnerDist + " @ Price : " + Constants.InnerFareRate + " cents", "Ok"); }
public PinsPage() { InitializeComponent(); Pin pinTokyo = null; Pin pinNewYork = null; // Tokyo pin buttonAddPinTokyo.Clicked += (sender, e) => { pinTokyo = new Pin() { Type = PinType.Place, Label = "Tokyo SKYTREE", Address = "Sumida-ku, Tokyo, Japan", Position = new Position(35.71d, 139.81d) }; pinTokyo.Clicked += Pin_Clicked; map.Pins.Add(pinTokyo); map.MoveToRegion(MapSpan.FromCenterAndRadius(pinTokyo.Position, Distance.FromMeters(5000))); ((Button)sender).IsEnabled = false; buttonRemovePinTokyo.IsEnabled = true; }; buttonRemovePinTokyo.Clicked += (sender, e) => { map.Pins.Remove(pinTokyo); pinTokyo.Clicked -= Pin_Clicked; pinTokyo = null; ((Button)sender).IsEnabled = false; buttonAddPinTokyo.IsEnabled = true; }; buttonRemovePinTokyo.IsEnabled = false; // New York pin buttonAddPinNewYork.Clicked += (sender, e) => { pinNewYork = new Pin() { Type = PinType.Place, Label = "Central Park NYC", Address = "New York City, NY 10022", Position = new Position(40.78d, -73.96d) }; pinNewYork.Clicked += Pin_Clicked; map.Pins.Add(pinNewYork); map.MoveToRegion(MapSpan.FromCenterAndRadius(pinNewYork.Position, Distance.FromMeters(5000))); ((Button)sender).IsEnabled = false; buttonRemovePinNewYork.IsEnabled = true; }; buttonRemovePinNewYork.Clicked += (sender, e) => { map.Pins.Remove(pinNewYork); pinNewYork.Clicked -= Pin_Clicked; pinNewYork = null; ((Button)sender).IsEnabled = false; buttonAddPinNewYork.IsEnabled = true; }; buttonRemovePinNewYork.IsEnabled = false; // Clear Pins buttonClearPins.Clicked += (sender, e) => { map.Pins.Clear(); if (pinTokyo != null) pinTokyo.Clicked -= Pin_Clicked; if (pinNewYork != null) pinNewYork.Clicked -= Pin_Clicked; pinTokyo = null; pinNewYork = null; buttonAddPinTokyo.IsEnabled = true; buttonAddPinNewYork.IsEnabled = true; buttonRemovePinTokyo.IsEnabled = false; buttonRemovePinNewYork.IsEnabled = false; }; // Select New York Pin buttonSelectPinNewYork.Clicked += (sender, e) => { if (pinNewYork == null) { DisplayAlert("Error", "New York is not added.", "Close"); return; } map.SelectedPin = pinNewYork; }; // Clear Pin Selection buttonClearSelection.Clicked += (sender, e) => { if (map.SelectedPin == null) { DisplayAlert("Error", "Pin is not selected.", "Close"); return; } map.SelectedPin = null; }; }
void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { mapn.Polylines.Clear(); var polygon = new Xamarin.Forms.GoogleMaps.Polygon(); polygon.Positions.Add(new Position(41.1389019841448d, -8.61560349288011d)); polygon.Positions.Add(new Position(41.1434744495776d, -8.67074812896517d)); polygon.Positions.Add(new Position(41.1449838609599d, -8.67905202242122d)); polygon.Positions.Add(new Position(41.1451299199957d, -8.67927438576518d)); polygon.Positions.Add(new Position(41.1667491884192d, -8.69051961393614d)); polygon.Positions.Add(new Position(41.1687515832633d, -8.69128901091482d)); polygon.Positions.Add(new Position(41.1687718202548d, -8.69129406942044d)); polygon.Positions.Add(new Position(41.1733985483824d, -8.6901233398917d)); polygon.Positions.Add(new Position(41.1791950462077d, -8.66638025932549d)); polygon.Positions.Add(new Position(41.1843186499419d, -8.64263275539779d)); polygon.Positions.Add(new Position(41.1859199810206d, -8.60475022412726d)); polygon.Positions.Add(new Position(41.1859353051989d, -8.60415557268555d)); polygon.Positions.Add(new Position(41.1858564905415d, -8.60352615847566d)); polygon.Positions.Add(new Position(41.1809534888858d, -8.57618203495341d)); polygon.Positions.Add(new Position(41.1808879776888d, -8.57596086663742d)); polygon.Positions.Add(new Position(41.1782338392238d, -8.56918812805673d)); polygon.Positions.Add(new Position(41.1781107344154d, -8.5690029395442d)); polygon.Positions.Add(new Position(41.1778608190979d, -8.56863743584061d)); polygon.Positions.Add(new Position(41.1776820677363d, -8.56838121049044d)); polygon.Positions.Add(new Position(41.1772845426276d, -8.56783274898752d)); polygon.Positions.Add(new Position(41.1761404097255d, -8.56630188826643d)); polygon.Positions.Add(new Position(41.1760550093552d, -8.56619263815834d)); polygon.Positions.Add(new Position(41.1759695143603d, -8.56610877045314d)); polygon.Positions.Add(new Position(41.1600578943756d, -8.55337925107515d)); polygon.Positions.Add(new Position(41.158207085713d, -8.55261345505833d)); polygon.Positions.Add(new Position(41.1532077014578d, -8.55473745611279d)); polygon.Positions.Add(new Position(41.1529458174769d, -8.55494508426352d)); polygon.Positions.Add(new Position(41.1463677636723d, -8.56368877972558d)); polygon.Positions.Add(new Position(41.1399578511665d, -8.57576315330342d)); polygon.Positions.Add(new Position(41.1383506797128d, -8.59418349674972d)); polygon.IsClickable = true; polygon.StrokeColor = Color.Black; polygon.StrokeWidth = 3f; polygon.FillColor = Color.FromRgba(255, 0, 0, 64); polygon.Tag = "POLYGON"; mapn.Polygons.Add(polygon); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); polyline.StrokeColor = Color.Blue; polyline.StrokeWidth = polyline.StrokeWidth * 4; var polylineinside = new Xamarin.Forms.GoogleMaps.Polyline(); polylineinside.StrokeColor = Color.Red; polylineinside.StrokeWidth = polyline.StrokeWidth * 2; foreach (var p in list) { polyline.Positions.Add(p); if (Contains(p, polygon)) { // point is inside polygon polylineinside.Positions.Add(p); } } mapn.Polylines.Add(polyline); if (polylineinside.Positions.Count > 2) { mapn.Polylines.Add(polylineinside); } var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = vm.startLabel, Address = vm.startAdd, Tag = "First Point", Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_location.png", WidthRequest = 25, HeightRequest = 25 }) }; mapn.Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = vm.endLabel, Address = vm.endAdd, Tag = "Last Point", Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_location_red.png", WidthRequest = 25, HeightRequest = 25 }) }; mapn.Pins.Add(pin1); int innerDist = 0; if (polylineinside.Positions.Count > 2) { var googleDirection = (vm.GetDistance(polylineinside.Positions.First(), polylineinside.Positions.Last()).Result); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { innerDist = googleDirection.Routes.FirstOrDefault().Legs.FirstOrDefault().Distance.Value; } } int totalDist = vm.CurrentGoogleDirection.Routes.FirstOrDefault().Legs.FirstOrDefault().Distance.Value; decimal totalfare = 0; decimal distanceunit = 0; decimal innerDistanceunit = 0; decimal outerDistanceunit = 0; int outerDist = totalDist - innerDist; decimal innerfare = (47m / (1000m / 300m)); decimal outerfare = (94m / (1000m / 300m)); if (innerDist > 0) { innerDistanceunit = (Convert.ToDecimal(innerDist) / 300m); outerDistanceunit = (Convert.ToDecimal(outerDist) / 300m); totalfare = (innerfare * innerDistanceunit) + (outerfare * outerDistanceunit); distanceunit = innerDistanceunit + outerDistanceunit; } else { distanceunit = (totalDist / 300m); totalfare = (outerfare * distanceunit); } mapn.MoveToRegion(MapSpan.FromPositions(list)); App.Current.MainPage.DisplayAlert("Price", "Total Distance : " + totalDist + " & Total Price : " + totalfare.ToString("F2") + "\nOuter Distance : " + outerDist + " @ Price : 94 cents" + "\nInner Distance : " + innerDist + " @ Price : 47 cents", "Ok"); }
protected abstract void OnUpdateIsVisible(Pin outerItem, TNative nativeItem);
protected abstract void OnUpdateAnchor(Pin outerItem, TNative nativeItem);
protected abstract void OnUpdateFlat(Pin outerItem, TNative nativeItem);
private void SetupMap() { if (map == null) { map = new Map { VerticalOptions = LayoutOptions.FillAndExpand, MapType = MapType.Street, MapStyle = MapStyle.FromJson(GetJson("map_style.json")), MyLocationEnabled = true, }; HomePageLayout.Children.Add(map); } Position position = new Position(54.393, 18.595); map.MoveToRegion(MapSpan.FromCenterAndRadius(position, new Distance(2500d))); map.UiSettings.ZoomGesturesEnabled = true; map.UiSettings.ScrollGesturesEnabled = true; map.UiSettings.IndoorLevelPickerEnabled = true; map.UiSettings.MyLocationButtonEnabled = true; map.UiSettings.ZoomControlsEnabled = true; map.UiSettings.CompassEnabled = false; map.UiSettings.TiltGesturesEnabled = false; map.UiSettings.RotateGesturesEnabled = false; string fileName = "icon_waiting.png"; string path = "Assets"; var assembly = typeof(MainPage).GetTypeInfo().Assembly; var stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{path}.{fileName}"); InitializePinsFromDb(); // Map Clicked map.MapClicked += (sender, e) => { var lat = e.Point.Latitude.ToString("0.000"); var lng = e.Point.Longitude.ToString("0.000"); this.DisplayAlert("MapClicked", $"{lat}/{lng}", "CLOSE"); }; // Map Long clicked map.MapLongClicked += (sender, e) => { double lat = e.Point.Latitude; double lng = e.Point.Longitude; Console.WriteLine(lat + " " + lng); Xamarin.Forms.GoogleMaps.Pin pin = new Xamarin.Forms.GoogleMaps.Pin() { Type = PinType.Place, Label = "", Address = "", Position = new Position(lat, lng), Icon = BitmapDescriptorFactory.FromStream(stream, id: fileName) }; pin.Clicked += (sender_pin, e_pin) => { PopupNavigation.PushAsync(new ShowMeetingPopupPage(pin, map)); }; map.Pins.Add(pin); map.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, map.VisibleRegion.Radius)); double top = CalculateBoundingCoordinates(map.VisibleRegion, "top"); double bottom = CalculateBoundingCoordinates(map.VisibleRegion, "bottom"); double y = lat - ((top - bottom) / 2); MapSpan span = new MapSpan(new Position(y, lng), map.VisibleRegion.LatitudeDegrees, map.VisibleRegion.LongitudeDegrees); map.MoveToRegion(span); PopupNavigation.PushAsync(new CreateMeetingPopupPage(pin, map)); }; }
internal PinClickedEventArgs(Pin pin) { this.Pin = pin; }
protected abstract void OnUpdateRotation(Pin outerItem, TNative nativeItem);
protected async override void OnAppearing() { //call parent function base.OnAppearing(); Model.locations = await Model.GetGroupedList(); try { var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10)); var location = await Geolocation.GetLocationAsync(request); if (location != null) { /*map.Pins.Add( * new Xamarin.Forms.GoogleMaps.Pin * { * Type = Xamarin.Forms.GoogleMaps.PinType.Generic, * Label = "Me", * Position = new Xamarin.Forms.GoogleMaps.Position(location.Latitude, location.Longitude), * //Icon = BitmapDescriptorFactory.FromBundle("C:\Users\Eli\Desktop\JellyBin02\JellyBin02\JellyBin02\JellyBin02.Android\Resources\drawable\pin1.png") * }); * * await App.Current.MainPage.DisplayAlert("Your Location", $"Latitude: {location.Latitude}, Longitude: {location.Longitude}", "OK");*/ System.Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}"); Model.MyLocation = location; } else { await App.Current.MainPage.DisplayAlert("Failed", "Could not get your location.", "OK"); } } catch (FeatureNotSupportedException fnsEx) { await App.Current.MainPage.DisplayAlert("Failed", fnsEx.Message, "OK"); } catch (PermissionException pEx) { await App.Current.MainPage.DisplayAlert("Failed", pEx.Message, "OK"); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Failed", ex.Message, "OK"); } map.MoveToRegion(Xamarin.Forms.GoogleMaps.MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(Model.MyLocation.Latitude, Model.MyLocation.Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(.5))); map.MapClicked += OnMapClicked; AddTrash.Clicked += ButtonClicked; map.Pins.Add( new Xamarin.Forms.GoogleMaps.Pin { Type = Xamarin.Forms.GoogleMaps.PinType.Place, Label = "Me", Position = new Xamarin.Forms.GoogleMaps.Position(Model.MyLocation.Latitude, Model.MyLocation.Longitude), Icon = Xamarin.Forms.GoogleMaps.BitmapDescriptorFactory.DefaultMarker(Color.Aqua) //Icon = BitmapDescriptorFactory.FromBundle("C:\Users\Eli\Desktop\JellyBin02\JellyBin02\JellyBin02\JellyBin02.Android\Resources\drawable\pin1.png") }); for (int i = 0; i < Model.locations.Count; i++) { /* * * 0 - black * 1 - green - food waste * 2 - purple - glass * 3 - brown = garden waste, food waste * 4 - blue - paper, card, plastic bottles, cans */ Color color; switch (Model.locations[i].colorID) { case 0: color = Color.Black; break; case 1: color = Color.Green; break; case 2: color = Color.Purple; break; case 3: color = Color.Brown; break; case 4: color = Color.Blue; break; default: color = Color.Red; break; } var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = Xamarin.Forms.GoogleMaps.PinType.Place, Label = Model.locations[i].isFull.ToString(), Position = new Xamarin.Forms.GoogleMaps.Position(Model.locations[i].lat, Model.locations[i].longit), Icon = Xamarin.Forms.GoogleMaps.BitmapDescriptorFactory.DefaultMarker(color) }; map.Pins.Add(pin); pin.Clicked += async(sender, e) => { string action = await DisplayActionSheet("Do you want to mark this bin as full?", "No", null, "Yes"); if (action == "Yes") { pin.Label = "full"; //await App.database.UpdateItem<Bin>(Model.locations[i]); } }; } }
async void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { searchLayout.IsVisible = true; stopRouteButton.IsVisible = false; Chamada.IsVisible = true; map.Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); polyline.StrokeColor = Color.Green; polyline.StrokeWidth = (float)5; foreach (var p in list) { polyline.Positions.Add(p); } map.Polylines.Add(polyline); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Xamarin.Forms.GoogleMaps.Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "First", Address = "First", Tag = string.Empty, Icon = BitmapDescriptorFactory.FromView(new Image() { Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25 }) }; map.Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Xamarin.Forms.GoogleMaps.Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = "Last", Address = "Last", Tag = string.Empty }; map.Pins.Add(pin1); //var medio = polyline.Positions.Count/ 2; //var pinmedio = new Xamarin.Forms.GoogleMaps.Pin //{ //Type = PinType.Place, //Position = new Position(polyline.Positions[medio].Latitude, polyline.Positions[medio].Longitude), //Label = "Medio", //Address = "Medio", //Tag = string.Empty, //}; //map.Pins.Add(pinmedio); inicio = pin.Position; fim = pin1.Position; map.MoveToRegion(MapSpan.FromPositions(list).WithZoom(0.85)); await StartListening(); }
bool Equals(Pin other) { return string.Equals(Label, other.Label) && Equals(Position, other.Position) && Type == other.Type && string.Equals(Address, other.Address); }
public CreateMeetingPopupPage(Xamarin.Forms.GoogleMaps.Pin pin, Xamarin.Forms.GoogleMaps.Map map) { InitializeComponent(); this.pin = pin; this.map = map; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += (sender, e) => { AppImage theImage = (AppImage)sender; imagePicked = theImage.ImageSource; Icon_1.Opacity = 0.4; Icon_2.Opacity = 0.4; Icon_3.Opacity = 0.4; Icon_4.Opacity = 0.4; Icon_5.Opacity = 0.4; Icon_6.Opacity = 0.4; Icon_7.Opacity = 0.4; Icon_8.Opacity = 0.4; Icon_9.Opacity = 0.4; Icon_10.Opacity = 0.4; activityPicked = theImage.ImageName; theImage.Opacity = 1; }; Editor.Focused += (sender, e) => { ChoseActivity.IsVisible = false; DateAndTime.IsVisible = false; DatePicker.IsVisible = false; TimePicker.IsVisible = false; Icon_1.IsVisible = false; Icon_2.IsVisible = false; Icon_3.IsVisible = false; Icon_4.IsVisible = false; Icon_5.IsVisible = false; Icon_6.IsVisible = false; Icon_7.IsVisible = false; Icon_8.IsVisible = false; Icon_9.IsVisible = false; Icon_10.IsVisible = false; }; Editor.Completed += (sender, e) => { ChoseActivity.IsVisible = true; DateAndTime.IsVisible = true; DatePicker.IsVisible = true; TimePicker.IsVisible = true; Icon_1.IsVisible = true; Icon_2.IsVisible = true; Icon_3.IsVisible = true; Icon_4.IsVisible = true; Icon_5.IsVisible = true; Icon_6.IsVisible = true; Icon_7.IsVisible = true; Icon_8.IsVisible = true; Icon_9.IsVisible = true; Icon_10.IsVisible = true; }; Icon_1.GestureRecognizers.Add(tapGestureRecognizer); Icon_2.GestureRecognizers.Add(tapGestureRecognizer); Icon_3.GestureRecognizers.Add(tapGestureRecognizer); Icon_4.GestureRecognizers.Add(tapGestureRecognizer); Icon_5.GestureRecognizers.Add(tapGestureRecognizer); Icon_6.GestureRecognizers.Add(tapGestureRecognizer); Icon_7.GestureRecognizers.Add(tapGestureRecognizer); Icon_8.GestureRecognizers.Add(tapGestureRecognizer); Icon_9.GestureRecognizers.Add(tapGestureRecognizer); Icon_10.GestureRecognizers.Add(tapGestureRecognizer); }
internal SelectedPinChangedEventArgs(Pin selectedPin) { this.SelectedPin = selectedPin; }
bool Equals(Pin other) { return(string.Equals(Label, other.Label) && Equals(Position, other.Position) && Type == other.Type && string.Equals(Address, other.Address)); }
protected abstract void OnUpdateAddress(Pin outerItem, TNative nativeItem);