public MapsPage() { InitializeComponent(); mpVM = this.BindingContext as MapsPageViewModel; InitializeMap(); isStart = true; }
public MapsPage() { NavigationPage.SetHasNavigationBar(this, false); VM = new MapsPageViewModel(); BindingContext = VM; InitializeComponent(); MyMap = new Map( MapSpan.FromCenterAndRadius( new Position(latitude: 27.9453715, longitude: -82.4659336), Distance.FromMiles(10))) { IsShowingUser = true, HeightRequest = Constants.Resources.ScreenHeight, WidthRequest = Constants.Resources.ScreenWidth, MapType = MapType.Hybrid }; mapLayout.Children.Add(MyMap); VM.MapPins.ForEach(pin => MyMap.Pins.Add(pin)); }
private async Task <List <Pin> > ShowPinsAsync() { var pins = new List <Pin>(); var mapsViewModel = MapsPageViewModel.GetInstance(); //********************************************************************* _user = JsonConvert.DeserializeObject <UserResponse>(Settings.User2); string url = App.Current.Resources["UrlAPI"].ToString(); string controller = string.Format("/AsignacionesOTs/GetAlls/{0}", _user.IDUser); Response <object> response = await _apiService.GetRemotesForUser( url, "api", controller, _user.IDUser); if (!response.IsSuccess) { IsEnabled = true; await App.Current.MainPage.DisplayAlert("Error", "Problema para recuperar datos.", "Aceptar"); } MyRemotes = (List <Reclamo>)response.Result; IEnumerable <RemoteItemViewModel> myListRemoteItemViewModel = MyRemotes.Select(a => new RemoteItemViewModel(_navigationService) { CantRem = a.CantRem, CAUSANTEC = a.CAUSANTEC, CLIENTE = a.CLIENTE, CodigoCierre = a.CodigoCierre, CP = a.CP, Descripcion = a.Descripcion, DOMICILIO = a.DOMICILIO, ENTRECALLE1 = a.ENTRECALLE1, ENTRECALLE2 = a.ENTRECALLE2, ESTADOGAOS = a.ESTADOGAOS, GRXX = a.GRXX, GRYY = a.GRYY, FechaAsignada = a.FechaAsignada, Novedades = a.Novedades, LOCALIDAD = a.LOCALIDAD, NOMBRE = a.NOMBRE, ObservacionCaptura = a.ObservacionCaptura, PROYECTOMODULO = a.PROYECTOMODULO, RECUPIDJOBCARD = a.RECUPIDJOBCARD, SUBCON = a.SUBCON, TELEFONO = a.TELEFONO, UserID = a.UserID, }); Remotes = new ObservableCollection <RemoteItemViewModel>(myListRemoteItemViewModel.OrderBy(o => o.FechaAsignada + o.NOMBRE)); //********************************************************************** foreach (var remote in mapsViewModel.Remotes.ToList()) { if (!string.IsNullOrEmpty(remote.GRXX) && !string.IsNullOrEmpty(remote.GRYY)) { if (remote.GRXX.Length > 5 && remote.GRYY.Length > 5) { var position = new Position(Convert.ToDouble(remote.GRXX), Convert.ToDouble(remote.GRYY)); var tipopin = new PinType(); tipopin = PinType.Place; var tipo = string.Empty; if (remote.PROYECTOMODULO == "Otro") { tipo = "CONTROL REMOTO"; } if (remote.PROYECTOMODULO == "Cable") { tipo = "RECUPERO CABLEVISION"; } if (remote.PROYECTOMODULO == "Tasa") { tipo = "RECUPERO TELEFONICA"; } pins.Add(new Pin { Label = tipo + " - " + remote.NOMBRE, Address = remote.DOMICILIO, Position = position, Type = tipopin, }); } } } foreach (var pin in pins) { MyMap.Pins.Add(pin); } return(pins); }