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; }); } }
private String GetReuseIdForPin(ExtendedPin model) { if (model.HasCustomPinImage()) { return($"{DEFAULT_IMAGE_REUSE_ID}{model.CustomPinImageName ?? ""}"); } return($"{DEFAULT_PUSHPIN_REUSE_ID}{model.PinColor}"); }
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); }
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; }
private UIButton GetDetailButton(ExtendedPin poi) { var detailButton = UIButton.FromType(UIButtonType.DetailDisclosure); detailButton.TouchUpInside += (s, e) => { if (_detailCommand != null) { _detailCommand.Execute(poi); } }; return(detailButton); }
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); }
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); } }
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); }); }
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; }
public static Boolean HasPlaceImage(this ExtendedPin item) { return(!String.IsNullOrWhiteSpace(item.ImageUrl)); }
public static Boolean HasCustomPinImage(this ExtendedPin item) { return(!String.IsNullOrWhiteSpace(item.CustomPinImageName)); }
public static Pin AsPin(this ExtendedPin item) { return(new Pin { Label = item.Name, Address = item.Details, Position = item.Location }); }