SachinAgrawal

Badges

Third AnniversarySecond AnniversaryFirst Anniversary5 Likes10 CommentsName DropperFirst Comment

About

Username
SachinAgrawal
Location
US
Joined
Visits
246
Last Active
Roles
University
Points
44
Badges
7

SachinAgrawal ✭✭

About

Username
SachinAgrawal
Location
US
Joined
Visits
246
Last Active
Roles
University
Points
44
Badges
7
  • Re: Custom renderer for Android Map like iOS map

    @Dquaglio your Custom-Renderer has to look like this.
    public class CustomMapViewRenderer : ViewRenderer<CustomMapView, global::Android.Gms.Maps.MapView>
    and then the methods below to to get the mapview and the googlemap initialized. Hope this helps.

    protected override void OnElementChanged(ElementChangedEventArgs e)
    {
    try
    {
    base.OnElementChanged(e);

                mapView = new MapView(this.Context);
                Bundle bundle = new Bundle();
                if(mapView != null)
                {
                    mapView.OnCreate(bundle);                    
                    MapsInitializer.Initialize(this.Context);
                    SetUpMapIfNeeded();                    
                    mapView.OnResume();
    
    
                    //remove the view from the parent container before refreshing/reloading the map page
                    ViewGroup parent = (ViewGroup)mapView.Parent;
                    if (parent != null)
                    {
                        parent.RemoveView(mapView);
                    }                   
    
                    SetNativeControl(mapView);                  
                }                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    
        private void SetUpMapIfNeeded()
        {
            if(null != _googleMap || _gettingMap) return;
    
            var mapReadyCallback = new GoogleMapOnReady();
            mapReadyCallback.MapReady += mapReadyCallback_MapReady;
    
            _gettingMap = true;           
            mapView.GetMapAsync(mapReadyCallback);
    
        }
    
        void mapReadyCallback_MapReady(object sender, EventArgs e)
        {
            _gettingMap = false;
            if (((GoogleMapOnReady)sender) != null)
                _googleMap = ((GoogleMapOnReady)sender).Map;
    
            if(_googleMap != null)
            {
                _googleMap.MapType = GoogleMap.MapTypeNormal;
                _googleMap.UiSettings.RotateGesturesEnabled = false;
                _googleMap.CameraChange += Map_CameraChange;
                MessagingCenter.Send<CustomMapView>(new CustomMapView(), "onmapchange");
            }           
        }
    

    public class GoogleMapOnReady : Java.Lang.Object, IOnMapReadyCallback
    {
    public GoogleMap Map { get; private set; }

        public event EventHandler MapReady;
    
        public void OnMapReady(GoogleMap googleMap)
        {
            Map = googleMap;
            var handler = MapReady;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }
    }
    
  • Re: Custom renderer for Android Map like iOS map

    Yeah, you should be able to embed map view within a XF page. Here is what my CustomMapView looks like which is in the PCL project

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Xamarin.Forms;
    using Xamarin.Forms.Maps;

    namespace XXXX
    {
    public class CustomMapView : View
    {
    public CustomMapView()
    {
    }
    public static readonly BindableProperty SelectedPinProperty = BindableProperty.Create<CustomMapView, CustomPin>(x => x.SelectedPin, new CustomPin { Label = "test123" });

        public CustomPin SelectedPin
        {
            get { return (CustomPin)base.GetValue(SelectedPinProperty); }
            set { base.SetValue(SelectedPinProperty, value); }
        }
    
        //public static readonly BindableProperty CustomPinsProperty = BindableProperty.Create<CustomMapView, List<CustomPin>>(x => x.CustomPins, new List<CustomPin>() { new CustomPin() { Label = "test123" } });
    
        //public List<CustomPin> CustomPins
        //{
        //    get { return (List<CustomPin>)base.GetValue(CustomPinsProperty); }
        //    set { base.SetValue(CustomPinsProperty, value); }
        //}
    
        public static readonly BindableProperty BusDataProperty = BindableProperty.Create<CustomMapView, BusData>(x => x.BusDataProp, new BusData());
    
        public BusData BusDataProp
        {
            get { return (BusData)base.GetValue(BusDataProperty); }
            set { base.SetValue(BusDataProperty, value); }
        }
    
        public static readonly BindableProperty SelectedInfoTextLine1Prop = BindableProperty.Create<CustomMapView, string>(x => x.InfoTextLine1,String.Empty,BindingMode.TwoWay);
        public string InfoTextLine1
        {
            get { return (string)base.GetValue(SelectedInfoTextLine1Prop); }
            set { base.SetValue(SelectedInfoTextLine1Prop, value); }
        }
    
        public static readonly BindableProperty SelectedInfoTextLine2Prop = BindableProperty.Create<CustomMapView, string>(x => x.InfoTextLine2, String.Empty, BindingMode.TwoWay);
        public string InfoTextLine2
        {
            get { return (string)base.GetValue(SelectedInfoTextLine2Prop); }
            set { base.SetValue(SelectedInfoTextLine2Prop, value); }
        }
    
        public static readonly BindableProperty HeaderRowProperty = BindableProperty.Create<CustomMapView, string>(x => x.HeaderRow, String.Empty, BindingMode.TwoWay);
        public string HeaderRow
        {
            get { return (string)base.GetValue(HeaderRowProperty); }
            set { base.SetValue(HeaderRowProperty, value); }
        }
    }
    

    }

  • Re: How to disable fullscreen keyboard in Xamarin Forms PCL project for Android devices in Landscape

    I had to do this:
    public class LoginLandscapeEntryRenderer : EntryRenderer
    {
    // Override the OnElementChanged method so we can tweak this renderer post-initial setup
    protected override void OnElementChanged(ElementChangedEventArgs e)
    {
    base.OnElementChanged(e);

            if (Control != null)
            {
                // do whatever you want to the textField here!
                //Control.SetBackgroundColor(global::Android.Graphics.Color.DarkGray);
                Control.ImeOptions = (ImeAction)ImeFlags.NoExtractUi;
            }
        }
    }
    
  • Publish Android App option disabled if custom solution configuration selected

    I am using Visual Studio 2013. I have a Xamarin Forms application. I am using Hockey app for the app to be downloaded and tested by our QA dept. I created custom solution configuration "QA' which is copied from Release.

    • I cannot "Publish the android app" if my current solution config is "QA" (copied from Release).
    • What would be the recommendation here?