Esempio n. 1
0
        public MapPage()
        {
            InitializeComponent();

            InfoFrame.BackgroundColor = IncidentTypeInfo.GetIncidentColor();

            _restService = new RestService();

            TopLabel.Text = $"Crimes Within A {CrimeFilterer.DistanceFilter}km Radius";

            SearchForCrime();

            userLocator = CrossGeolocator.Current;
        }
Esempio n. 2
0
        protected async Task CreatePins()
        {
            activityIndicator.IsRunning = true;

            // Get list of crime incidents from local database, filtering according to the requested filter
            Incident[] incidents = (await CrimeFilterer.Filter()).ToArray();

            numOfIncidentsLabel.Text  = $"{incidents.Length} Incidents";
            InfoFrame.BackgroundColor = IncidentTypeInfo.GetIncidentColor();

            crimeMap.Pins.Clear();

            // Create a pin for each for incident
            for (int i = 0; i < incidents.Length; i++)
            {
                Incident incident = incidents[i];

                // initialize pin
                CustomPin pin = new CustomPin
                {
                    Type     = PinType.Place,
                    Position = new Position(incident.Latitude, incident.Longitude),
                    Label    = $"{incident.Type}",
                    Address  = $"{incident.Description}"
                };

                // add pin
                crimeMap.Pins.Add(pin);
            }

            if (crimeMap.Pins.Count > 0)
            {
                var lastPin = crimeMap.Pins.First();

                // Move map to Location with crime pins
                MapSpan mapSpan = MapSpan.FromCenterAndRadius(new Position(lastPin.Position.Latitude, lastPin.Position.Longitude), Distance.FromKilometers(4));
                crimeMap.MoveToRegion(mapSpan);
            }

            activityIndicator.IsRunning = false;
        }