private void addAnnotations(SQLite.TableQuery <MagpieIOS.MagpieBadge> table)
        {
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var dbPath    = Path.Combine(documents, "db_sqlite-net.db");
            var db        = new SQLiteConnection(dbPath);


            int index = 0;

            foreach (MagpieBadge badge in table)
            {
                double lat  = table.ElementAt(index).lat;
                double lon  = table.ElementAt(index).lon;
                String name = table.ElementAt(index).bname;
                String sub  = table.ElementAt(index).art + " - " + table.ElementAt(index).year;

                //if iscollected check
                String q         = "SELECT * FROM MagpieUser WHERE bid = " + table.ElementAt(index).bid;
                var    userTuple = db.Query <MagpieUser>(q);

                if (userTuple.ElementAt(0).isClaimed.Equals(""))
                {
                    var annotation = new AnnotationModel(new CLLocationCoordinate2D(lat, lon), name, index, false, sub);
                    map.AddAnnotation(annotation);
                }
                else
                {
                    var annotation = new AnnotationModel(new CLLocationCoordinate2D(lat, lon), name, index, true, sub);
                    map.AddAnnotation(annotation);
                }

                index++;
            }
        }
        private void initializeMap()
        {
            CLLocationManager locationManager = new CLLocationManager();

            locationManager.RequestWhenInUseAuthorization();
            locationManager.RequestAlwaysAuthorization();             //requests permission for access to location data while running in the background

            map.ShowsUserLocation = true;

            map.DidUpdateUserLocation += (sender, e) =>
            {
                if (map.UserLocation != null && !locationUPDATED && selected.Equals("-1"))
                {
                    //this would constantly move map back to user location
                    CLLocationCoordinate2D coords    = map.UserLocation.Coordinate;
                    MKCoordinateRegion     mapRegion = MKCoordinateRegion.FromDistance(coords, 100, 100);
                    map.Region      = mapRegion;
                    locationUPDATED = true;
                }
                if (!selected.Equals("-1"))
                {
                    getDistanceTime(currAnnoLocation, map.UserLocation.Coordinate);
                }
            };

            //if user location not accesible start at this location
            if (!map.UserLocationVisible)
            {
                CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(47.658779, -117.426048);
                MKCoordinateRegion     mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 100, 100);
                map.CenterCoordinate = mapCenter;
                map.Region           = mapRegion;
            }

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var dbPath    = Path.Combine(documents, "db_sqlite-net.db");
            var db        = new SQLiteConnection(dbPath);

            if (selected.Equals("-1"))
            {
                viewBadgeBtn.Enabled     = false;
                SculptureTitle.Text      = "Your location";
                SculptureSubtitle.Text   = "";
                DistanceAway.Text        = "0";
                milesTo.Text             = "0";
                milesToLabel.Hidden      = true;
                DistanceAwayLabel.Hidden = true;
                milesTo.Hidden           = true;
                DistanceAway.Hidden      = true;
            }
            else
            {
                var startInfo = db.Query <MagpieBadge>("SELECT * FROM MagpieBadge WHERE bid = " + selected);
                SculptureTitle.Text    = startInfo[0].bname;
                SculptureSubtitle.Text = startInfo[0].art + " - " + startInfo[0].year;
                CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(startInfo[0].lat, startInfo[0].lon);
                map.SetCenterCoordinate(mapCenter, true);
                currAnnoLocation     = mapCenter;
                viewBadgeBtn.Enabled = true;
                int i = 0;
                foreach (CLLocationCoordinate2D a in annotationScrollList)
                {
                    if (a.Latitude.Equals(currAnnoLocation.Latitude))
                    {
                        currentAnno = i;
                        break;
                    }
                    else
                    {
                        i++;
                    }
                }
            }



            //styling
            SculptureTitle.Font         = UIFont.FromName("Montserrat-Light", 19f);
            SculptureSubtitle.Font      = UIFont.FromName("Montserrat-Medium", 18f);
            SculptureSubtitle.TextColor = UIColor.Gray;
            milesTo.Font                = UIFont.FromName("Montserrat-Medium", 20f);
            DistanceAway.Font           = UIFont.FromName("Montserrat-Medium", 20f);
            milesToLabel.Font           = UIFont.FromName("Montserrat-Light", 20f);
            DistanceAwayLabel.Font      = UIFont.FromName("Montserrat-Light", 20f);
            milesToLabel.TextColor      = UIColor.Gray;
            DistanceAwayLabel.TextColor = UIColor.Gray;
            //end styling


            map.GetViewForAnnotation = GetViewForAnnotation;

            map.DidSelectAnnotationView += (object sender, MKAnnotationViewEventArgs e) =>
            {
                annoList = map.SelectedAnnotations;
                foreach (IMKAnnotation a in annoList)
                {
                    SculptureTitle.Text    = a.GetTitle();
                    SculptureSubtitle.Text = a.GetSubtitle();
                    getDistanceTime(a.Coordinate, map.UserLocation.Coordinate);
                    currAnnoLocation     = new CLLocationCoordinate2D(a.Coordinate.Latitude, a.Coordinate.Longitude);
                    viewBadgeBtn.Enabled = true;
                    int i = 0;
                    foreach (CLLocationCoordinate2D annot in annotationScrollList)
                    {
                        if (annot.Longitude.Equals(currAnnoLocation.Longitude))
                        {
                            currentAnno = i;
                            if (annot.Longitude.Equals(a.Coordinate.Longitude))
                            {
                                AnnotationModel m = a as AnnotationModel;
                                this.selected = m.GetID().ToString();
                            }
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
            };

            LeftAnnotation.TouchUpInside += (sender, e) =>
            {
                CLLocationCoordinate2D anno = annotationScrollList[currentAnno];

                map.SetCenterCoordinate(anno, true);

                getDistanceTime(anno, map.UserLocation.Coordinate);

                var table = db.Query <MagpieBadge>("SELECT * FROM MagpieBadge WHERE lon = " + anno.Longitude);
                SculptureTitle.Text    = table[0].bname;
                SculptureSubtitle.Text = table[0].art + " - " + table[0].year;
                this.selected          = table[0].bid;

                if (currentAnno == 0)
                {
                    currentAnno = annotationScrollList.Count - 1;
                }
                else
                {
                    currentAnno--;
                }

                viewBadgeBtn.Enabled = true;
            };

            RightAnnotation.TouchUpInside += (sender, e) =>
            {
                CLLocationCoordinate2D anno = annotationScrollList[currentAnno];

                map.SetCenterCoordinate(anno, true);

                getDistanceTime(anno, map.UserLocation.Coordinate);

                var table = db.Query <MagpieBadge>("SELECT * FROM MagpieBadge WHERE lon = " + anno.Longitude);
                SculptureTitle.Text    = table[0].bname;
                SculptureSubtitle.Text = table[0].art + " - " + table[0].year;
                this.selected          = table[0].bid;

                if (currentAnno == annotationScrollList.Count - 1)
                {
                    currentAnno = 0;
                }
                else
                {
                    currentAnno++;
                }
                viewBadgeBtn.Enabled = true;
            };


            _btnCurrentLocation.TouchUpInside += (sender, e) =>
            {
                map.SetCenterCoordinate(map.UserLocation.Location.Coordinate, true);
                currentAnno = 0;

                SculptureTitle.Text    = "Your location";
                SculptureSubtitle.Text = "";
                DistanceAway.Text      = "0";
                milesTo.Text           = "0";

                DistanceAway.Hidden      = true;
                milesTo.Hidden           = true;
                milesToLabel.Hidden      = true;
                DistanceAwayLabel.Hidden = true;

                viewBadgeBtn.Enabled = false;

                selected = "-1";
            };
            View.AddSubview(_btnCurrentLocation);
        }