void AddStoreAnnotations(List <GroceryStore> stores)
 {
     foreach (var store in stores)
     {
         var storeAnnotation = new StoreAnnotation(store);
         //make sure we dont already have the annotation
         bool alreadyContainsAnnotation = false;
         foreach (var annotation in map.Annotations)
         {
             StoreAnnotation mapAnnotationAsStore = annotation as StoreAnnotation;
             if (mapAnnotationAsStore != null)
             {
                 if (mapAnnotationAsStore.Address == store.Address)
                 {
                     alreadyContainsAnnotation = true;
                     break;
                 }
             }
         }
         if (!alreadyContainsAnnotation)
         {
             map.AddAnnotation(storeAnnotation);
         }
     }
 }
        void AddStoreAnnotations()
        {
            var stores = StoreFactory.GetStores();

            foreach (var store in stores)
            {
                var annotation = new StoreAnnotation(store);
                map.AddAnnotation(annotation);
            }
        }
Example #3
0
        public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
        {
            StoreAnnotation storeAnnotation = view.Annotation as StoreAnnotation;

            if (storeAnnotation != null)
            {
                var coord = storeAnnotation.Coordinate;

                var destination = new MKMapItem(new MKPlacemark(coord, (MKPlacemarkAddress)null));
                ShowDirections(destination, mapView);
            }
        }