Exemplo n.º 1
0
        public static MapboxMapOptions CreateOptions(
            this Naxam.Controls.Forms.MapView element,
            Context context)
        {
            var mapboxMapOptions = new MapboxMapOptions();

            if (string.IsNullOrWhiteSpace(element.ApiBaseUri))
            {
                mapboxMapOptions.InvokeApiBaseUri(element.ApiBaseUri);
            }

            mapboxMapOptions.InvokeCamera(element.Camera.ToNative())
            .InvokeZoomGesturesEnabled(element.ZoomEnabled)           //, true));
            .InvokeScrollGesturesEnabled(element.ScrollEnabled)       //, true));
            .InvokeRotateGesturesEnabled(element.RotateEnabled)       //, true));
            .InvokeTiltGesturesEnabled(element.PitchEnabled)          //, true));
            .InvokeDoubleTapGesturesEnabled(element.DoubleTapEnabled) // , true));
            .InvokeQuickZoomGesturesEnabled(element.QuickZoomEnabled) //, true));
            .InvokeMaxZoomPreference(element.ZoomMaxLevel ?? MapboxConstants.MAXIMUM_ZOOM)
            .InvokeMinZoomPreference(element.ZoomMinLevel ?? MapboxConstants.MINIMUM_ZOOM)
            .InvokeCompassEnabled(element.CompassEnabled)                 //, true));
            .InvokeCompassGravity((int)element.CompassGravity)            // Gravity.TOP | Gravity.END));
            .CompassMargins(element.CompassMargin.ToArray(context))       //FOUR_DP
            .CompassFadesWhenFacingNorth(element.CompassFadeFacingNorth); //, true));

            var compassDrawableName = (element.CompassDrawable as FileImageSource)?.File.Split('.')[0]
                                      ?? "mapbox_compass_icon";
            var compassDrawableId =
                context.Resources.GetIdentifier(compassDrawableName, "drawable", context.PackageName);

            if (compassDrawableId > 0)
            {
                var compassDrawable = context.Resources.GetDrawable(compassDrawableId, context.Theme);
                mapboxMapOptions.InvokeCompassImage(compassDrawable);
            }

            mapboxMapOptions.InvokeLogoEnabled(element.LogoEnabled)                   //, true));
            .InvokeLogoGravity((int)element.LogoGravity)                              //, Gravity.BOTTOM | Gravity.START));
            .LogoMargins(element.LogoMargin.ToArray(context))                         //FOUR_DP
            .InvokeAttributionTintColor(element.AttributionTintColor.ToAndroid())     //, UNDEFINED_COLOR));
            .InvokeAttributionEnabled(element.AttributionEnabled)                     //, true));
            .InvokeAttributionGravity((int)element.AttributionGravity)                //, Gravity.BOTTOM | Gravity.START));
            .AttributionMargins(element.AttributionMargin.ToArray(context))           // NINETY_TWO_DP FOUR_DP  FOUR_DP FOUR_DP
            .InvokeTextureMode(element.RenderTextureMode)                             //, false));
            .InvokeTranslucentTextureSurface(element.RenderTextureTranslucentSurface) //, false));
            .SetPrefetchesTiles(element.TilePrefetchEnabled)                          //, true));
            .InvokeRenderSurfaceOnTop(element.ZMediaOverlayEnabled);                  //, false));

            mapboxMapOptions.LocalIdeographFontFamilyEnabled(element.LocalIdeographFontFamilyEnabled)
            .InvokeLocalIdeographFontFamily(element.LocalIdeographFontFamilies ??
                                            new[] { MapboxConstants.DEFAULT_FONT }) //, true);
            .InvokePixelRatio(element.PixelRatio)                                   //, 0);
            .InvokeForegroundLoadColor(element.ForegroundLoadColor.ToAndroid())     //, LIGHT_GRAY)
            .InvokeCrossSourceCollisions(element.CrossSourceCollisions);            //, true)
            return(mapboxMapOptions);
        }
Exemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <FCCMapBox> e)
        {
            base.OnElementChanged(e);

            MapboxMapOptions options = new MapboxMapOptions();

            options.InvokeScrollGesturesEnabled(true);
            options.InvokeRotateGesturesEnabled(true);
            options.InvokeTiltGesturesEnabled(true);
            options.InvokeZoomGesturesEnabled(true);

            _MapView = new MapView(Context, options);
            _MapView.OnCreate(null);
            _MapView.SetStyle(Mapbox.Constants.Style.MapboxStreets);
            _MapView.GetMapAsync();
            SetNativeControl(_MapView);
        }
        protected override async void OnElementChanged(ElementChangedEventArgs <MapBoxControl> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                //MapboxAccountManager.Start(Context, "pk.eyJ1IjoidmVzc2VsYXBwIiwiYSI6ImNqZml0ems1YzBndDcyenFxdTFmbXFya3EifQ.O2v_RvniaVAkYE3rQVjw3A");

                MapboxMapOptions options = new MapboxMapOptions();
                options.InvokeScrollGesturesEnabled(true);
                options.InvokeRotateGesturesEnabled(true);
                options.InvokeTiltGesturesEnabled(true);
                options.InvokeZoomGesturesEnabled(true);

                Map          = new MapView(Context, options);
                Map.StyleUrl = "mapbox://styles/vesselapp/cjfj2i5rgcq8t2rqgj5spfzvk";
                Map.OnCreate(null);
                Map.GetMap(this);

                SetNativeControl(Map);
            }
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Mapbox.GetInstance(this, "YOUR API KEY HERE");

            Mapbox.SetConnected(Java.Lang.Boolean.True);

            MapboxMapOptions options = new MapboxMapOptions()
                                       .InvokeCamera(new CameraPosition.Builder()
                                                     .Target(new LatLng(29.7604, -95.3698))
                                                     .Zoom(8)
                                                     .Build());

            // create map
            mapView = new MapView(this, options);

            mapView.OnCreate(savedInstanceState);

            mapView.GetMapAsync(this);

            SetContentView(mapView);
        }