示例#1
0
        private void NativePinOnTap(object sender, System.Windows.Input.GestureEventArgs gestureEventArgs)
        {
            var nativePin = (Pushpin)sender;

            var contentArray = nativePin.Content.ToString().Split('\n');

            var label       = contentArray[0];
            var description = contentArray[1];

            _selectedPin = new ExtendedPin
            {
                Label    = label,
                Address  = description,
                Position = new Position(nativePin.GeoCoordinate.Latitude, nativePin.GeoCoordinate.Longitude)
            };

            _formsMap.SelectedPinAddress = description;

            if (_customMapContentView.Footer.FooterMode == FooterMode.Hidden)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    _customMapContentView.Footer.FooterMode = FooterMode.Minimized;
                });
            }
        }
示例#2
0
        private String GetReuseIdForPin(ExtendedPin model)
        {
            if (model.HasCustomPinImage())
            {
                return($"{DEFAULT_IMAGE_REUSE_ID}{model.CustomPinImageName ?? ""}");
            }

            return($"{DEFAULT_PUSHPIN_REUSE_ID}{model.PinColor}");
        }
示例#3
0
        private void AddPin(ExtendedPin formsPin)
        {
            var nativePin =
                new ExtendedMapAnnotation(new CLLocationCoordinate2D(formsPin.Position.Latitude, formsPin.Position.Longitude),
                                          formsPin.Label, formsPin.Address, formsPin.PinIcon);

            nativePin.Clicked += HandleAnnotationClick;

            _nativeMapView.AddAnnotation(nativePin);
        }
示例#4
0
        private void HandleMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var marker = e.Marker;

            marker.ShowInfoWindow();

            var map = this.Element as ExtendedMap;

            var formsPin = new ExtendedPin(marker.Title, marker.Snippet, marker.Position.Latitude, marker.Position.Longitude);

            map.SelectedPin = formsPin;
        }
示例#5
0
        private UIButton GetDetailButton(ExtendedPin poi)
        {
            var detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);

            detailButton.TouchUpInside += (s, e) =>
            {
                if (_detailCommand != null)
                {
                    _detailCommand.Execute(poi);
                }
            };

            return(detailButton);
        }
示例#6
0
        private UIImageView GetImage(ExtendedPin poi)
        {
            var imageView = new UIImageView(new CGRect(5d, 5d, 75d, 75d));

            if (poi.ImageUrl != null)
            {
                Task.Run(async() =>
                {
                    var image = await LoadImage(poi.ImageUrl);

                    InvokeOnMainThread(() =>
                    {
                        imageView.Image = image;
                    });
                });
            }

            return(imageView);
        }
示例#7
0
        private MKAnnotationView CreateViewForPin(IMKAnnotation annotation, ExtendedPin model)
        {
            if (model.HasCustomPinImage())
            {
                var pinImageName = $"{model.CustomPinImageName}.png";

                var view = new MapAnnotationView(annotation, GetReuseIdForPin(model));
                view.Image        = UIImage.FromBundle(pinImageName);
                view.CenterOffset = new CGPoint(0, -15);

                return(view);
            }
            else
            {
                var view = new MKPinAnnotationView(annotation, GetReuseIdForPin(model));
                view.PinColor = GetPinColor(model.PinColor);

                return(view);
            }
        }
示例#8
0
        private void AddFormsPinToNativeMap(ExtendedPin formsPin)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                var nativePin  = new Pushpin();
                nativePin.Tap += NativePinOnTap;

                var geoCoordinate       = new GeoCoordinate(formsPin.Position.Latitude, formsPin.Position.Longitude);
                nativePin.GeoCoordinate = geoCoordinate;
                nativePin.Content       = formsPin.Label + "\n" + formsPin.Address;

                var nativePinMapOverlay           = new MapOverlay();
                nativePinMapOverlay.Content       = nativePin;
                nativePinMapOverlay.GeoCoordinate = geoCoordinate;

                var mapLayer = new MapLayer();
                mapLayer.Add(nativePinMapOverlay);

                _nativeMap.Layers.Add(mapLayer);
            });
        }
示例#9
0
        private void AddPin(ExtendedPin formsPin)
        {
            var androidMapView = (MapView)Control;

            var markerWithIcon = new MarkerOptions();

            markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude));
            markerWithIcon.SetTitle(formsPin.Label);
            markerWithIcon.SetSnippet(formsPin.Address);

            if (!string.IsNullOrEmpty(formsPin.PinIcon))
            {
                markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(GetResourceIdByName(formsPin.PinIcon)));
            }
            else
            {
                markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
            }

            androidMapView.Map.AddMarker(markerWithIcon);
        }
        private void HandleMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var marker = e.Marker;
            marker.ShowInfoWindow ();

            var map = this.Element as ExtendedMap;

            var formsPin = new ExtendedPin (marker.Title, marker.Snippet, marker.Position.Latitude, marker.Position.Longitude);

            map.SelectedPin = formsPin;
        }
示例#11
0
 public static Boolean HasPlaceImage(this ExtendedPin item)
 {
     return(!String.IsNullOrWhiteSpace(item.ImageUrl));
 }
示例#12
0
 public static Boolean HasCustomPinImage(this ExtendedPin item)
 {
     return(!String.IsNullOrWhiteSpace(item.CustomPinImageName));
 }
示例#13
0
 public static Pin AsPin(this ExtendedPin item)
 {
     return(new Pin {
         Label = item.Name, Address = item.Details, Position = item.Location
     });
 }