Exemplo n.º 1
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            ViewModel = BindingContext as MapMainPageModel;

            if (ViewModel == null)
            {
                return;
            }

            #region Map_Pins_Set

            ViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "Customers")
                {
                    if (ViewModel.Customers != null && ViewModel.Customers.Count >= 0)
                    {
                        SetPins(ViewModel);
                    }
                }
                else if (e.PropertyName == "AllPartners")
                {
                    (BindingContext as MapMainPageModel).FilterVisibleRegion(Map.VisibleRegion);
                    bt_search.IsVisible = true;
                }
            };

            SetPins(ViewModel);

            #endregion
        }
Exemplo n.º 2
0
        void SetPins(MapMainPageModel context)
        {
            if ((Map.Pins != null) && (Map.Pins.Count > 0))
            {
                Map.Pins.Clear();
            }

            if (context.Customers != null)
            {
                foreach (var cust in context.Customers)
                {
                    if (cust.PartnerLatitude != 0 && cust.PartnerLongitude != 0)
                    {
                        var pin = new Pin()
                        {
                            Address     = cust.ContactAddress,
                            IsDraggable = false,
                            Flat        = true,
                            Label       = cust.Name,
                            Type        = PinType.SavedPin,
                            IsVisible   = true,
                            Icon        = BitmapDescriptorFactory.FromView(new BindingPinView(string.IsNullOrWhiteSpace(cust.Name) ? "P" : cust.Name.Trim().Substring(0, 1), Convert(cust.LastCheckinAt))),
                            Position    = new Position(cust.PartnerLatitude.HasValue ? cust.PartnerLatitude.Value : 0, cust.PartnerLongitude.HasValue ? cust.PartnerLongitude.Value : 0)
                        };
                        Map.Pins.Add(pin);
                    }
                }
            }

            if (!Map.Pins.Contains(MyPin) && !string.IsNullOrEmpty(MyPin.Label))
            {
                Map.Pins.Add(MyPin);
            }
        }