Пример #1
0
        private void CreateAnnotation(AvailableVehicle vehicle)
        {
            var annotationType = (vehicle is AvailableVehicleCluster)
                ? AddressAnnotationType.NearbyTaxiCluster
                : AddressAnnotationType.NearbyTaxi;

            var vehicleAnnotation = new AddressAnnotation(
                new CLLocationCoordinate2D(vehicle.Latitude, vehicle.Longitude),
                annotationType,
                vehicle.VehicleName,
                string.Empty,
                _useThemeColorForPickupAndDestinationMapIcons,
                false,
                vehicle.LogoName,
                vehicle.Market,
                vehicle.CompassCourse,
                ViewModel.Settings.ShowAssignedVehicleNumberOnPin,
                showOrientation: ViewModel.Settings.ShowOrientedPins);

            vehicleAnnotation.HideMedaillonsCommand = new AsyncCommand(() =>
            {
                var annotations = Annotations.Where(annotation => !annotation.Equals(vehicleAnnotation))
                                  .Select(ViewForAnnotation)
                                  .Select(annotation => annotation as PinAnnotationView)
                                  .Where(view => view != null);

                foreach (var pinAnnotationView in annotations)
                {
                    pinAnnotationView.HideMedaillon();
                }
            });

            AddAnnotation(vehicleAnnotation);
            _availableVehicleAnnotations.Add(vehicleAnnotation);
        }
Пример #2
0
        private void ShowAvailableVehicles(IEnumerable <AvailableVehicle> vehicles)
        {
            // remove currently displayed pushpins
            foreach (var pp in _availableVehiclePushPins)
            {
                RemoveAnnotation(pp);
            }

            _availableVehiclePushPins.Clear();

            if (vehicles == null)
            {
                return;
            }

            foreach (var v in vehicles)
            {
                var annotationType = (v is AvailableVehicleCluster)
                                     ? AddressAnnotationType.NearbyTaxiCluster
                                     : AddressAnnotationType.NearbyTaxi;

                var pushPin = new AddressAnnotation(
                    new CLLocationCoordinate2D(v.Latitude, v.Longitude),
                    annotationType,
                    string.Empty,
                    string.Empty,
                    _useThemeColorForPickupAndDestinationMapIcons,
                    false,
                    v.LogoName);

                AddAnnotation(pushPin);
                _availableVehiclePushPins.Add(pushPin);
            }
        }
Пример #3
0
 private void SetAnnotation(Address address, AddressAnnotation addressAnnotation, bool visible)
 {
     if (address.HasValidCoordinate() && visible)
     {
         RemoveAnnotation(addressAnnotation);
         addressAnnotation.SetCoordinate(address.GetCoordinate());
         AddAnnotation(addressAnnotation);
     }
     else
     {
         RemoveAnnotation(addressAnnotation);
     }
 }
Пример #4
0
        private void Initialize()
        {
            var settings        = TinyIoCContainer.Current.Resolve <IAppSettings>().Data;
            var locationService = TinyIoCContainer.Current.Resolve <ILocationService>();

            _showAssignedVehicleNumberOnPin = settings.ShowAssignedVehicleNumberOnPin;
            _useThemeColorForPickupAndDestinationMapIcons = this.Services().Settings.UseThemeColorForMapIcons;

            var initialPosition = locationService.GetInitialPosition();

            var region = new MKCoordinateRegion(new CLLocationCoordinate2D(initialPosition.Latitude, initialPosition.Longitude), new MKCoordinateSpan(0.1, 0.1));

            Region = region;

            this.DelayBind(() =>
            {
                var set = this.CreateBindingSet <OrderMapView, MapViewModel>();

                set.Bind()
                .For(v => v.PickupAddress)
                .To(vm => vm.PickupAddress);

                set.Bind()
                .For(v => v.DestinationAddress)
                .To(vm => vm.DestinationAddress);

                set.Bind()
                .For(v => v.AddressSelectionMode)
                .To(vm => vm.AddressSelectionMode);

                set.Bind()
                .For("AvailableVehicles")
                .To(vm => vm.AvailableVehicles);

                set.Bind()
                .For("IsMapDisabled")
                .To(vm => vm.IsMapDisabled);

                set.Apply();
            });

            _pickupAnnotation      = GetAnnotation(new CLLocationCoordinate2D(), AddressAnnotationType.Pickup, _useThemeColorForPickupAndDestinationMapIcons);
            _destinationAnnotation = GetAnnotation(new CLLocationCoordinate2D(), AddressAnnotationType.Destination, _useThemeColorForPickupAndDestinationMapIcons);

            InitializeGesture();

            // Show glowing blue dot
            ShowsUserLocation = true;
        }
Пример #5
0
        // Update Annotation and Animate it to see it move on the map
        private void UpdateAnnotation(AddressAnnotation annotationToUpdate, AvailableVehicle vehicle)
        {
            var annotationType = (vehicle is AvailableVehicleCluster)
                ? AddressAnnotationType.NearbyTaxiCluster
                : AddressAnnotationType.NearbyTaxi;

            annotationToUpdate.Degrees = ViewModel.Settings.ShowOrientedPins
                                            ? vehicle.CompassCourse
                                          : 0;
            annotationToUpdate.AddressType = annotationType;

            AnimateAnnotationOnMap(annotationToUpdate, new Position {
                Latitude = vehicle.Latitude, Longitude = vehicle.Longitude
            });
        }
Пример #6
0
        private void ShowPickupPin(Address address)
        {
            if (_pickupPin != null)
            {
                RemoveAnnotation(_pickupPin);
                _pickupPin = null;
            }

            if (address == null)
            {
                return;
            }

            var coords = address.GetCoordinate();

            if (coords.Latitude != 0 && coords.Longitude != 0)
            {
                _pickupPin = new AddressAnnotation(coords, AddressAnnotationType.Pickup, Localize.GetValue("PickupMapTitle"), address.Display(), _useThemeColorForPickupAndDestinationMapIcons, false);
                AddAnnotation(_pickupPin);
            }
        }
Пример #7
0
        public OrderMapView(IntPtr handle) : base(handle)
        {
            Initialize();

            _dropoffCenterPin = new UIImageView(AddressAnnotation.GetImage(AddressAnnotationType.Destination))
            {
                BackgroundColor = UIColor.Clear,
                ContentMode     = UIViewContentMode.Center,
                Hidden          = true
            };

            _pickupCenterPin = new UIImageView(AddressAnnotation.GetImage(AddressAnnotationType.Pickup))
            {
                BackgroundColor = UIColor.Clear,
                ContentMode     = UIViewContentMode.Center,
                Hidden          = true
            };

            RegionChanged += (s, e) =>
            {
                var canShowClusterizedTaxiMarker = ViewModel != null && !ViewModel.Settings.ShowIndividualTaxiMarkerOnly;

                if (canShowClusterizedTaxiMarker && CanShowAvailableVehicle())
                {
                    ShowAvailableVehicles(VehicleClusterHelper.Clusterize(AvailableVehicles != null ? AvailableVehicles.ToArray() : null, GetMapBoundsFromProjection()));
                }

                if (TaxiLocation != null && !_automatedMapChanged)
                {
                    CancelAutoFollow.ExecuteIfPossible();
                }
                else if (_automatedMapChanged)
                {
                    _automatedMapChanged = false;
                }
            };
        }
Пример #8
0
 private void DeleteAnnotation(AddressAnnotation annotationToRemove)
 {
     RemoveAnnotation(annotationToRemove);
     _availableVehicleAnnotations.Remove(annotationToRemove);
 }