private void AppOnNewMessageReceveid(object sender, Techie techie) { Device.BeginInvokeOnMainThread(() => { lock (Lock) { MapControl.SelectedPin = null; var p = techie.LastLocation; var t = Users.FirstOrDefault(x => x.ID == techie.Id); if (t == null) { t = new TKCustomMapPin() { ID = techie.Id, Image = techie.ProfileIcon, Title = techie.Username }; Users.Add(t); } t.Position = new Position(p.Coordinates[0], p.Coordinates[1]); t.Subtitle = techie.Email; MapControl.SelectedPin = t; } }); }
public MainViewModel() { instance = this; Pins = new ObservableCollection <Pin>(); Locations = new ObservableCollection <TKCustomMapPin>(); locations = new ObservableCollection <TKCustomMapPin>(); LocationsSearch = new ObservableCollection <TKCustomMapPin>(); locationsSearch = new ObservableCollection <TKCustomMapPin>(); listlocation = new ObservableCollection <ListRequest>(); myPosition = new TKCustomMapPin(); LocationsRequest = new ObservableCollection <PinRequest>(); apiService = new ApiService(); Menu = new ObservableCollection <MenuItemViewModel>(); EncabezadoMenu = new MenuItemViewModel(); navigationService = new NavigationService(); NewLogin = new LoginViewModel(); Agenda = new AgendaViewModel(); PasswordVM = new PasswordViewModel(); // CheckinClient = new CheckinViewModel(); MyPin = new TKCustomMapPin(); tapCommand = new Command <object>(ProfileClient); tapCommand2 = new Command <object>(PinClient); SearchCommand = new Command <string>(async(text) => SearchClient(text)); LoadClientes(); if (Settings.IsLoggedIn) { // Agenda.init(); Locator(); } }
private void clicked_Clicked(object sender, EventArgs e) { Device.BeginInvokeOnMainThread(() => { var x = new ObservableCollection <TKCustomMapPin>(); x.Clear(); for (var i = 0; i < 50; i++) { var f = new TKCustomMapPin(); f.Position = new Position(37 + i, -122); f.Title = "asfgasg"; f.IsVisible = true; f.DefaultPinColor = Color.AliceBlue; // f.Image = ImageSource.FromResource(ImageNameFromResource("icon.png")); f.Anchor = Point.Zero; } custom.Pins = x; custom.IsVisible = true; custom.IsShowingUser = true; custom.IsRegionChangeAnimated = true; custom.HasZoomEnabled = true; custom.HasScrollEnabled = true; custom.ShowTraffic = true; custom.MapType = MapType.Street; //works only when inisialized custom.MoveToMapRegion(MapSpan.FromCenterAndRadius(new Position(37, -122), Distance.FromMiles(1))); }); }
public async void EntregasPendientes() { Locations.Clear(); Distribuidor distribuidor = new Distribuidor { IdDistribuidor = Settings.IdDistribuidor, }; var response = await ApiServices.InsertarAsync <Distribuidor>(distribuidor, new Uri(Constants.BaseApiAddress), "/api/Compras/MisVentasPendientes"); ListaClientes = JsonConvert.DeserializeObject <List <CompraResponse> >(response.Result.ToString()); Point p = new Point(0.48, 0.96); foreach (var cliente in ListaClientes) { var Pindistribuidor = new TKCustomMapPin { Image = "casa", Position = new TK.CustomMap.Position((double)cliente.Latitud, (double)cliente.Longitud), Title = cliente.NombreCliente + "", Subtitle = "Nro tanques: " + cliente.Cantidad, Anchor = p, ShowCallout = true, }; Locations.Add(Pindistribuidor); } ListaClientes.Count(); }
private void OnPinClicked(TKCustomMapPin pin) { var firstPosition = Pins.First().Position; var position = pin.Position; // if the user tapped the first marker, we'll close the gap. // and prevent them from adding more points. _allowedToAddPoint = _allowedToAddPoint && Pins.Count > 1 && !(Math.Abs(position.Latitude - firstPosition.Latitude) <= 0 && Math.Abs(position.Longitude - firstPosition.Longitude) <= 0); if (!_allowedToAddPoint) { var polygon = new TKPolygon { Color = Color.FromHex("#7f000000"), StrokeColor = Color.Black, StrokeWidth = 2 }; foreach (var line in Polylines) { polygon.Coordinates.AddRange(line.LineCoordinates); } Polylines.Clear(); Polygons.Clear(); Pins.Clear(); Polygons.Add(polygon); } }
/// <summary> /// Adds a marker to the map /// </summary> /// <param name="pin">The Forms Pin</param> private async void AddPin(TKCustomMapPin pin) { pin.PropertyChanged += OnPinPropertyChanged; var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); if (!string.IsNullOrWhiteSpace(pin.Title)) { markerWithIcon.SetTitle(pin.Title); } if (!string.IsNullOrWhiteSpace(pin.Subtitle)) { markerWithIcon.SetSnippet(pin.Subtitle); } await this.UpdateImage(pin, markerWithIcon); markerWithIcon.Draggable(pin.IsDraggable); markerWithIcon.Visible(pin.IsVisible); if (pin.Image != null) { markerWithIcon.Anchor((float)pin.Anchor.X, (float)pin.Anchor.Y); } this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon)); }
/// <summary> /// Remove a pin from the map and the internal dictionary /// </summary> /// <param name="pin">The pin to remove</param> private void RemovePin(TKCustomMapPin pin, bool removeMarker = true) { var item = this._markers[pin]; if (item == null) { return; } if (this._selectedMarker != null) { if (item.Id.Equals(this._selectedMarker.Id)) { this.FormsMap.SelectedPin = null; } } item.Remove(); pin.PropertyChanged -= OnPinPropertyChanged; if (removeMarker) { this._markers.Remove(pin); } }
/// <summary> /// Updates the image on a marker /// </summary> /// <param name="pin">The forms pin</param> /// <param name="marker">The native marker</param> private async Task UpdateImage(TKCustomMapPin pin, Marker marker) { BitmapDescriptor bitmap; try { if (pin.Image != null) { bitmap = BitmapDescriptorFactory.FromBitmap(await pin.Image.ToBitmap(this.Context)); } else { if (pin.DefaultPinColor != Color.Default) { var hue = pin.DefaultPinColor.ToAndroid().GetHue(); bitmap = BitmapDescriptorFactory.DefaultMarker(hue); } else { bitmap = BitmapDescriptorFactory.DefaultMarker(); } } } catch (Exception) { bitmap = BitmapDescriptorFactory.DefaultMarker(); } marker.SetIcon(bitmap); }
public PinDescriptor(DeserializeGetMarkersData item) { var tags = item.SubCategories.ToTagsString(); var todayWorkTime = item.WorkTime.FirstOrDefault( d => d.Id.ToDayOfWeek() == DateTime.Now.DayOfWeek); var workTime = (todayWorkTime != null) ? todayWorkTime.OpenTime.Hours + ":" + (todayWorkTime.OpenTime.Minutes < 10 ? "0" + todayWorkTime.OpenTime.Minutes : todayWorkTime.OpenTime.Minutes.ToString()) + " - " + todayWorkTime.CloseTime.Hours + ":" + (todayWorkTime.CloseTime.Minutes < 10 ? "0" + todayWorkTime.CloseTime.Minutes : todayWorkTime.CloseTime.Minutes.ToString()) : TextResource.Closed; OpenTime = todayWorkTime?.OpenTime; CloseTime = todayWorkTime?.CloseTime; if (todayWorkTime != null && todayWorkTime.OpenTime == todayWorkTime.CloseTime) { workTime = TextResource.EvryTime; OpenTime = null; CloseTime = null; } Pin = new TKCustomMapPin { Id = item.Id, Position = new Position(item.Lat, item.Lng), Title = item.Name, Image = item.Icon, InfoImage = item.Logo, ShowCallout = false, IsDraggable = false, WorkTime = workTime, Tags = tags }; CategoriesBranch = item.CategoriesBranch; IsVisible = false; WiFi = item.Wifi; Personal = item.Personal; }
public Confirmacion(TKCustomMapPin posicion) { viewModel = new ConfirmacionViewModel(posicion); BindingContext = viewModel; InitializeComponent(); Debug.WriteLine(posicion.Position.Latitude); }
private void WeatherLoaded(object sender, EventArgs e) { var pins = new List <TKCustomMapPin>(); foreach (var city in contentProvider.Cities) { var position = new Position(Convert.ToDouble(city.Latitude), Convert.ToDouble(city.Longitude)); var wind = GetWindDirection(city.WindDegree); var sorce = GetWindImageDirection(wind); var pin = new TKCustomMapPin { Image = sorce, Position = position, Title = city.Name, Anchor = new Point(0, 0), Subtitle = city.CurrentWeather, IsCalloutClickable = true, ShowCallout = true, }; pins.Add(pin); } citiesMap.Pins = pins; citiesMap.PinSelected += CitiesMap_PinSelected; citiesMap.MapClicked += CitiesMap_MapClicked; CenterMap(); }
public MainViewModel() { instance = this; Pins = new ObservableCollection <Pin>(); Locations = new ObservableCollection <TKCustomMapPin>(); locations = new ObservableCollection <TKCustomMapPin>(); listlocation = new ObservableCollection <ListRequest>(); myPosition = new TKCustomMapPin(); LocationsRequest = new ObservableCollection <PinRequest>(); apiService = new ApiService(); Menu = new ObservableCollection <MenuItemViewModel>(); EncabezadoMenu = new MenuItemViewModel(); navigationService = new NavigationService(); NewLogin = new LoginViewModel(); AddnewClient = new AddViewModel(); CheckinClient = new CheckinViewModel(); signalRService = new SignalRService(); LoadClientes(); if (Settings.IsLoggedIn) { Locator(); } }
private async void PinClient(object obj) { TKCustomMapPin cliente = (TKCustomMapPin)obj; IsSearch = false; MoveTo(cliente.Position); MyPin = locations.Where(x => x.Title == cliente.Title).FirstOrDefault(); }
public ConfirmacionViewModel(TKCustomMapPin posicion) { centerSearch = (MapSpan.FromCenterAndRadius(posicion.Position, Distance.FromMiles(.3))); CenterSearch = centerSearch; locations = new ObservableCollection <TKCustomMapPin>(); Locations.Add(posicion); Direccion = Settings.Direccion; }
/// <summary> /// Adds a pin /// </summary> /// <param name="pin">The pin to add</param> private void AddPin(TKCustomMapPin pin) { var annotation = new TKCustomMapAnnotation(pin); Map.MapElements.Add(annotation.MapIcon); pin.PropertyChanged += OnPinPropertyChanged; _pins.Add(annotation.MapIcon, annotation); }
/// <summary> /// Adds a pin /// </summary> /// <param name="pin">The pin to add</param> private void AddPin(TKCustomMapPin pin) { var pinControl = new TKCustomBingMapsPin(pin, Map); Map.Children.Add(pinControl); _pins.Add(pin, pinControl); pinControl.Observe(true); }
protected virtual void OnPinSelected(TKCustomMapPin pin) { var ev = this.PinSelected; if (ev != null) { ev(this, new PinSelectedEventArgs(pin)); } }
private void AdicionarPedido(string key, DistribuidorFirebase pedido) { // Locations.Clear(); try { if (!isVisible) { Point p = new Point(0.48, 0.96); var found = Camiones.FirstOrDefault(x => x.id == pedido.id); if (found != null) { int i = Camiones.IndexOf(found); Camiones[i] = pedido; int y = Locations.IndexOf(Locations.FirstOrDefault(x => x.ID == pedido.id.ToString())); Locations.RemoveAt(y); var Pindistribuidor = new TKCustomMapPin { Image = "camion", Position = new TK.CustomMap.Position((double)pedido.Latitud, (double)pedido.Longitud), Anchor = p, ShowCallout = true, ID = pedido.id.ToString() }; Locations.Add(Pindistribuidor); //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Locations")); } else { Camiones.Add(new DistribuidorFirebase() { id = pedido.id, Latitud = pedido.Latitud, Longitud = pedido.Longitud, }); var Pindistribuidor = new TKCustomMapPin { Image = "camion", Position = new TK.CustomMap.Position((double)pedido.Latitud, (double)pedido.Longitud), Anchor = p, ShowCallout = true, ID = pedido.id.ToString() }; Locations.Add(Pindistribuidor); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public MapViewModel(List <ComplainRequest> _ListDenuncia) { Locator(); locations = new ObservableCollection <TKCustomMapPin>(); Locations.Clear(); _listdenuncia = new List <ComplainRequest>(); ListDenuncia.Clear(); foreach (var denuncia in _ListDenuncia) { ListDenuncia.Add(denuncia); var cachedImage = new CachedImage() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, DownsampleToViewSize = true, Transformations = new System.Collections.Generic.List <ITransformation>() { new GrayscaleTransformation(), new CircleTransformation(), }, Source = denuncia.Photo, CacheType = FFImageLoading.Cache.CacheType.Disk }; string imagenPin = ""; Color colorpin = Color.White; if (denuncia.IdSubcategory < 3) { imagenPin = "qpt_mov"; colorpin = Color.Blue; } else if (denuncia.IdSubcategory < 6) { imagenPin = "qpt_edu"; colorpin = Color.Red; } else if (denuncia.IdSubcategory < 9) { imagenPin = "qpt_inc"; colorpin = Color.Yellow; } var pin = new TKCustomMapPin { Position = new TK.CustomMap.Position((double)denuncia.Latitude, (double)denuncia.Longitude), Title = denuncia.Title, Subtitle = denuncia.Description, DefaultPinColor = colorpin, ShowCallout = true, }; Locations.Add(pin); } }
public void AddPin(Position position, string title) { TKCustomMapPin pin = new TKCustomMapPin { Position = position, IsDraggable = true, ShowCallout = true, Title = title, }; Pins.Add(pin); }
public void addSolutionPin(Position position, String street) { var pin = new TKCustomMapPin { Position = position, ShowCallout = true, DefaultPinColor = Color.LawnGreen, Title = "Correct Location", Subtitle = street }; this._pins.Add(pin); }
/// <summary> /// Creates a new instance of <see cref="TKCustomBingMapsPin"/> /// </summary> /// <param name="pin">The <see cref="TKCustomMapPin"/></param> /// <param name="map">The <see cref="MapControl"/></param> public TKCustomBingMapsPin(TKCustomMapPin pin, MapControl map) { _formsPin = pin; _map = map; InitializeComponent(); _dragStartTimer.Tick += (o, e) => { StartDragging(); _dragStartTimer.Stop(); }; Initialize(); }
public ConfirmacionViewModel(TKCustomMapPin posicion) { try { centerSearch = (MapSpan.FromCenterAndRadius(posicion.Position, Distance.FromMiles(.3))); CenterSearch = centerSearch; locations = new ObservableCollection <TKCustomMapPin>(); Locations.Add(posicion); Direccion = Settings.Direccion; } catch (Exception ex) { Debug.Write(ex.Message); } }
/// <summary> /// Creates a new instance of <see cref="TKCustomMapAnnotation"/> /// </summary> /// <param name="pin">The forms pin</param> public TKCustomMapAnnotation(TKCustomMapPin pin) { _formsPin = pin; _coordinate = pin.Position.ToLocationCoordinate(); _formsPin.PropertyChanged += formsPin_PropertyChanged; MapIcon = new MapIcon { Title = Title, //mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///pin.png")); CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible, Location = Coordinate, NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0) }; }
/// <summary> /// Set the image of the annotation view /// </summary> /// <param name="annotationView">The annotation view</param> /// <param name="pin">The forms pin</param> private void UpdateImage(MapIcon annotationView, TKCustomMapPin pin) { if (pin.Image != null) { Device.BeginInvokeOnMainThread(async() => { annotationView.Image = await pin.Image.ToUWPImageSource(); }); } else { // TODO how? //Device.BeginInvokeOnMainThread(() => //{ // annotationView.Image = null; //}); } }
public HomeViewModel(INavigationService navigationService) : base(navigationService) { Icon = "map.png"; Title = "Home"; SelectedPin = new TKCustomMapPin(); SelectedPin.IsDraggable = true; Pins = new ObservableCollection <TKCustomMapPin>(); Cars = new ObservableCollection <Car>(); Drivers = new ObservableCollection <Driver>(); SelectedCar = new Car(); SelectedDriver = new Driver(); Drag = new Command(drag); Drop = new Command(drop); OrderCMD = new Command(orderAsync); Carrepository = new CarsRepository(App.DbPath); DriverRepo = new DriverRepository(App.DbPath); Requestrepo = new RequestRepository(App.DbPath); }
private void MapReady(object sender, EventArgs e) { var position = new TK.CustomMap.Position(Convert.ToDouble(city.Latitude), Convert.ToDouble(city.Longitude)); var pin = new TKCustomMapPin { Image = (this.BindingContext as MasterDetailPageDetailViewModel).WindDirectionImageSource, Position = position, Title = city.Name, Anchor = new Point(0, 0), Subtitle = city.CurrentWeather, IsCalloutClickable = true, ShowCallout = true, }; cityMap.Pins = new List <TKCustomMapPin> { pin }; cityMap.MapRegion = MapSpan.FromCenterAndRadius(position, Distance.FromMiles(1)); }
public async void LoadClientes() { try { var clientes = await apiService.GetMyClient(); Locations = new ObservableCollection <TKCustomMapPin>(); LocationsSearch.Clear(); ListLocation.Clear(); clientes.Count(); if (clientes != null && clientes.Count > 0) { Point p = new Point(0.48, 0.96); foreach (var cliente in clientes) { var Pincliente = new TKCustomMapPin { Image = "pin.png", Position = new Xamarin.Forms.Maps.Position(cliente.Latitud, cliente.Longitud), Anchor = p, Title = "Razón Social: " + cliente.RazonSocial, Subtitle = "Dirección: " + cliente.Direccion, ShowCallout = true, }; var itemcliente = new ListRequest { Titulo = "Razón Social: " + cliente.RazonSocial, Subtitulo = cliente.Direccion + " " + cliente.Telefono, idCliente = cliente.IdCliente, }; Locations.Add(Pincliente); ListLocation.Add(itemcliente); listlocationAux.Add(itemcliente); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public override async void OnAppearing(object navigationContext) { base.OnAppearing(navigationContext); try { IsBusy = true; CurrentLocationAsync(); var result = await EventsMobileService.Instance.ReadEventsItemsAsync(); if (result != null) { var events = new ObservableCollection <Event>(result); foreach (var e in events) { var position = new Position(e.Latitude, e.Longitude); // Latitude, Longitude var pin = new TKCustomMapPin { ID = e.Id, Title = e.Name, Subtitle = e.Description, IsDraggable = false, Position = position, ShowCallout = true }; this._pins.Add(pin); } } } catch (System.Threading.Tasks.TaskCanceledException ex) { Debug.WriteLine(ex.Message); } finally { IsBusy = false; } }
async void ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (IPlaceResult)e.SelectedItem; try { var Address = prediction.Description; addlbl.Text = Address; Settings.Placeto = addlbl.Text; Orderbtn.IsVisible = true; var locations = await Geocoding.GetLocationsAsync(Address); var location = locations?.FirstOrDefault(); if (location != null) { Settings.Latto = location.Latitude.ToString(); Settings.Lngto = location.Longitude.ToString(); var newPin = new TKCustomMapPin { Position = new Position(location.Latitude, location.Longitude), Title = "Cluster Test", Image = "placeholder.png" }; Pins.Clear(); Pins.Add(newPin); ToMap.Pins = Pins; ToMap.MoveToMapRegion(MapSpan.FromCenterAndRadius( new Position(location.Longitude, location.Longitude), Distance.FromKilometers(50)), true); Orderbtn.IsVisible = true; } } catch (Exception ex) { } // HandleItemSelected(prediction); }
/// <summary> /// Creates a new instance of <see cref="TKCustomMapAnnotation"/> /// </summary> /// <param name="pin">The forms pin</param> public TKCustomMapAnnotation(TKCustomMapPin pin) { this._formsPin = pin; }