示例#1
0
        //View do PINO
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            //Exclui se o ponto for a posição do usuário
            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var PinoFoto = ((MapAnnotation)annotation).PinoFoto;


            if (PinoFoto == null)
            {
                throw new Exception("Pino não encontrado");
            }

            MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(PinoFoto.POST.Id.ToString());

            if (annotationView == null)
            {
                annotationView = new CustomMKAnnotationView(annotation, PinoFoto.POST.Id.ToString());
                ((CustomMKAnnotationView)annotationView).POST = PinoFoto.POST;

                annotationView.Image         = UIImage.FromFile("PinoFoto.png");
                annotationView.CenterOffset  = new CGPoint(0, -28.5);
                annotationView.CalloutOffset = new CGPoint(0, 0);
            }
            annotationView.CanShowCallout = false;

            return(annotationView);
        }
示例#2
0
        //Get IMAGEM DE URL ASYNC
        async Task ImageFromUrl(UIImageView IMAGE, string imageUrl, CustomMKAnnotationView AV)
        {
            var           httpClient   = new HttpClient();
            Task <byte[]> contentsTask = httpClient.GetByteArrayAsync(imageUrl);
            var           contents     = await contentsTask;

            IMAGE.Image    = UIImage.LoadFromData(NSData.FromArray(contents));
            AV.ImagemCache = NSData.FromArray(contents);
        }
示例#3
0
        //CLICA NO PINO e ABRE A FOTO
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            if (customPinView != null)
            {
                customPinView.RemoveFromSuperview();
                customPinView.Dispose();
                customPinView = null;
            }

            customPinView = new UIView();
            customPinView.BackgroundColor = UIColor.White;
            customPinView.Frame           = new CGRect(0, 0, 130, 160);

            //Nome do usuário
            var TXTNome = new UILabel(new CGRect(5, 5, 120, 20));

            TXTNome.Text = ((MapAnnotation)e.View.Annotation).PinoFoto.POST.UsuarioDados.Nome;
            customPinView.AddSubview(TXTNome);

            //IMG
            var image = new UIImageView(new CGRect(5, 30, 120, 120));

            customPinView.AddSubview(image);

            CustomMKAnnotationView AV = ((CustomMKAnnotationView)e.View);

            if (AV.ImagemCache != null)
            {
                image.Image = UIImage.LoadFromData(AV.ImagemCache);
            }
            else
            {
                ImageFromUrl(image, ((MapAnnotation)e.View.Annotation).PinoFoto.POST.FotoURLMiniatura, AV);
            }

            customPinView.Center = new CGPoint(25, -(e.View.Frame.Height + 25));

            e.View.AddSubview(customPinView);

            //CLICA NA FOTO
            customPinView.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                touchOnCustonPinView = true;
                ((MapAnnotation)e.View.Annotation).PinoFoto.ClicaPino();
            }));
        }