Example #1
0
        MGLAnnotationView MapView_ImageForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            MapView.ScrollEnabled = false;
            var mapAnnotation  = mapView.Annotations;
            var itemAnnotation = Element.Annotations.Cast <Annotation>().ToArray();
            var title          = annotation.GetTitle();
            var mapType        = "";
            var color          = "";

            foreach (var item in itemAnnotation)
            {
                var itemAnn = item as PointAnnotation;
                if (title.Equals(itemAnn.Title))
                {
                    color   = itemAnn.Color;
                    mapType = itemAnn.MapType;
                }
            }
            var imageName = "";

            if (color == "red" && mapType == "comrades")
            {
                imageName = "map_army_red_small";
            }
            if (color == "yellow" && mapType == "comrades")
            {
                imageName = "map_army_yellow_small";
            }
            if (color == "green" && mapType == "comrades")
            {
                imageName = "map_army_green_small";
            }
            if (color == "red" && mapType == "recruit")
            {
                imageName = "map_red_small";
            }
            if (color == "yellow" && mapType == "recruit")
            {
                imageName = "map_yellow_small";
            }
            if (color == "green" && mapType == "recruit")
            {
                imageName = "map_green_small";
            }
            var annotationImage = MapView.DequeueReusableAnnotationViewWithIdentifier(title);

            if (annotationImage == null)
            {
                var iosImage = new UIImage(imageName);
                if (iosImage != null)
                {
                    iosImage = iosImage.ImageWithAlignmentRectInsets(new UIEdgeInsets(0, 0, iosImage.Size.Height / 2, 0));
                    //return MGLAnnotationImage.AnnotationImageWithImage(iosImage, title);
                    var customMGL = new CustomMGLPolyline(title, iosImage);
                    //customMGL.CenterOffset = new CGVector(-8, 0);
                    return(customMGL);
                }
            }
            return(annotationImage);
        }
Example #2
0
        public MGLAnnotationView ViewForAnnotation(IMGLAnnotation annotation)
        {
            if (annotation is MyCustomPointAnnotation)
            {
                var anno = (MyCustomPointAnnotation)annotation;
                if (!anno.WillUseImage)
                {
                    return(null);
                }
                var reuseIdentifier = "reusableDotView";

                // For better performance, always try to reuse existing annotations.
                var annotationView = mapView.DequeueReusableAnnotationViewWithIdentifier(reuseIdentifier);
                if (annotationView == null)
                {
                    annotationView       = new MGLAnnotationView(reuseIdentifier);
                    annotationView.Frame = new CGRect(0, 0, 30, 30);
                    annotationView.Layer.CornerRadius = (annotationView.Frame.Size.Width) / 2;
                    annotationView.Layer.BorderWidth  = (nfloat)4.0;
                    annotationView.Layer.BorderColor  = UIColor.White.CGColor;
                    annotationView.BackgroundColor    = new UIColor((nfloat)0.03, (nfloat)0.80, (nfloat)0.69, (nfloat)1.0);
                }

                return(annotationView);
            }
            else
            {
                return(null);
            }
        }
        public MGLAnnotationView MapView_ViewForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            var fannotation = Element.Annotations.FirstOrDefault(x => x.NativeHandle == annotation.Handle);

            switch (fannotation)
            {
                case SymbolAnnotation symbol:
                    if (symbol.IconImage?.Source != null)
                    {
                        return null;
                    }
                    break;
            }

            var annotationView = mapView.DequeueReusableAnnotationViewWithIdentifier("draggablePoint");
            if (annotationView != null) return annotationView;
            var view = new DraggableAnnotationView(reuseIdentifier: "draggablePoint", size: 24);
            view.DragFinished += (sender, e) =>
            {
                var point = new SymbolAnnotation();
                point.NativeHandle = annotation.Handle;
                point.Coordinates = annotation.Coordinate.ToLatLng();
                Element.DragFinishedCommand?.Execute(point);
            };

            view.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
            {
                Element.DidTapOnMarkerCommand?.Execute(fannotation.Id);
            }));

            //mapView.SelectAnnotation(annotation, true, null);

            return view;
        }
        public MGLAnnotationImage MapView_ImageForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            var fannotation = Element.Annotations.FirstOrDefault(x => x.NativeHandle == annotation.Handle);

            switch (fannotation)
            {
                case SymbolAnnotation symbol:
                    switch (symbol.IconImage.Source)
                    {
                        case FileImageSource fileImageSource:
                            var cachedImage = mapView.DequeueReusableAnnotationImageWithIdentifier(fileImageSource.File);

                            if (cachedImage != null) return cachedImage;

                            var fileImageSourceHandler = new FileImageSourceHandler();
                            var image = fileImageSourceHandler.LoadImageAsync(fileImageSource).Result;

                            if (image == null) return null;

                            return MGLAnnotationImage.AnnotationImageWithImage(image, fileImageSource.File);
                    }
                    break;
            }

            return null;
        }
        public MGLAnnotationView MapView_ViewForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            var fannotation = Element.Annotations.FirstOrDefault(x => x.NativeHandle == annotation.Handle);

            switch (fannotation)
            {
            case SymbolAnnotation symbol:
                if (symbol.IconImage?.Source != null)
                {
                    return(null);
                }
                break;
            }

            var annotationView = mapView.DequeueReusableAnnotationViewWithIdentifier("draggablePoint");

            if (annotationView != null)
            {
                return(annotationView);
            }
            var view = new DraggableAnnotationView(reuseIdentifier: "draggablePoint", size: 24);

            view.DragFinished += (sender, e) =>
            {
                var point = new SymbolAnnotation();
                point.NativeHandle = annotation.Handle;
                point.Coordinates  = annotation.Coordinate.ToLatLng();
                Element.DragFinishedCommand?.Execute(point);
            };

            return(view);
        }
 protected virtual bool AnnotationCanShowCallout(MGLMapView mapView, IMGLAnnotation annotation)
 {
     if (annotation is MGLShape && Element.CanShowCalloutChecker != null)
     {
         return Element.CanShowCalloutChecker.Invoke(((MGLShape)annotation).Id());
     }
     return true;
 }
        public MGLAnnotationImage MapView_ImageForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            var annotationImage = mapView.DequeueReusableAnnotationImageWithIdentifier("temple");

            if (annotationImage == null)
            {
                var image = UIImage.FromBundle("temple");
                image           = image.ImageWithAlignmentRectInsets(new UIEdgeInsets(0, 0, image.Size.Height / 2, 0));
                annotationImage = MGLAnnotationImage.AnnotationImageWithImage(image, "temple");
            }
            return(annotationImage);
        }
        public IMGLCalloutView MapView_CalloutViewForAnnotation(MGLMapView mapView, IMGLAnnotation annotation)
        {
            var id = annotation.Handle;
            if (mapView.Annotations != null)
            {
                var bindingContext = Element.Annotations.FirstOrDefault(a => a.NativeHandle == id);
                UIView calloutContent = Element.InfoWindowTemplate.DataTemplateToNativeView(bindingContext, Element);
                return new MGLCustomCalloutView(null, calloutContent);
            }

            return null;
        }
Example #9
0
 public static global::CoreLocation.CLLocationCoordinate2D GetCoordinate(this IMGLAnnotation This)
 {
     global::CoreLocation.CLLocationCoordinate2D ret;
     if (Runtime.Arch == Arch.DEVICE)
     {
         if (IntPtr.Size == 8)
         {
             ret = global::ApiDefinition.Messaging.CLLocationCoordinate2D_objc_msgSend(This.Handle, Selector.GetHandle("coordinate"));
         }
         else
         {
             global::ApiDefinition.Messaging.CLLocationCoordinate2D_objc_msgSend_stret(out ret, This.Handle, Selector.GetHandle("coordinate"));
         }
     }
     else if (IntPtr.Size == 8)
     {
         ret = global::ApiDefinition.Messaging.CLLocationCoordinate2D_objc_msgSend(This.Handle, Selector.GetHandle("coordinate"));
     }
     else
     {
         global::ApiDefinition.Messaging.CLLocationCoordinate2D_objc_msgSend_stret(out ret, This.Handle, Selector.GetHandle("coordinate"));
     }
     return(ret);
 }
 public bool MapView_AnnotationCanShowCallout(MGLMapView mapView, IMGLAnnotation annotation)
 {
     return(true);
 }
Example #11
0
 public MGLAnnotationView ViewForAnnotation(IMGLAnnotation annotation)
 {
     return(null);
 }
Example #12
0
 public static string GetSubtitle(this IMGLAnnotation This)
 {
     return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("subtitle"))));
 }