AndroidBitmapDescriptor GetRaw(BitmapDescriptor descriptor, Context context)
        {
            switch (descriptor.Type)
            {
            case BitmapDescriptorType.Default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker((float)((descriptor.Color.Hue * 360f) % 360f)));

            case BitmapDescriptorType.Bundle:
                var bundleName = descriptor.BundleName;
                if (!bundleName.Contains('.'))
                {
                    bundleName += ".png";
                }
                if (UseGoogleMapsFactory || descriptor.IconScale == 1 || descriptor.IconScale == 0)
                {
                    return(AndroidBitmapDescriptorFactory.FromAsset(bundleName));
                }
                return(AndroidBitmapDescriptorFactory.FromBitmap(GetBitmapFromAsset(descriptor, context)));

            case BitmapDescriptorType.Stream:
                if (descriptor.Stream.CanSeek && descriptor.Stream.Position > 0)
                {
                    descriptor.Stream.Position = 0;
                }
                return(AndroidBitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(descriptor.Stream)));

            case BitmapDescriptorType.AbsolutePath:
                return(AndroidBitmapDescriptorFactory.FromPath(descriptor.AbsolutePath));

            default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker());
            }
        }
Пример #2
0
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            int resId = 0;

            switch (descriptor.Id)
            {
            case "GREEN":
                resId = Resource.Drawable.active_lot;
                break;

            case "ORANGE":
                resId = Resource.Drawable.going_to_filled_out;
                break;

            case "RED":
                resId = Resource.Drawable.filled_lot;
                break;

            case "GREY":
                resId = Resource.Drawable.selected_lot;
                break;

            case "YELLOW":
                resId = Resource.Drawable.map_current;
                break;
            }

            return(AndroidBitmapDescriptorFactory.FromResource(resId));
        }
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            switch (descriptor.Type)
            {
            case BitmapDescriptorType.Default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker((float)((descriptor.Color.Hue * 360f) % 360f)));

            case BitmapDescriptorType.Bundle:
                var context    = FormsGoogleMaps.Context;
                var resourceId = context.Resources.GetIdentifier(descriptor.BundleName, "drawable", context.PackageName);
                return(AndroidBitmapDescriptorFactory.FromResource(resourceId));

            case BitmapDescriptorType.Stream:
                if (descriptor.Stream.CanSeek && descriptor.Stream.Position > 0)
                {
                    descriptor.Stream.Position = 0;
                }
                return(AndroidBitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(descriptor.Stream)));

            case BitmapDescriptorType.AbsolutePath:
                return(AndroidBitmapDescriptorFactory.FromPath(descriptor.AbsolutePath));

            default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker());
            }
        }
Пример #4
0
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            switch (descriptor.Type)
            {
            case BitmapDescriptorType.Default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker((float)((descriptor.Color.Hue * 360f) % 360f)));

            case BitmapDescriptorType.Bundle:
                return(AndroidBitmapDescriptorFactory.FromAsset(descriptor.BundleName));

            case BitmapDescriptorType.Resource:
                var d = Xamarin.Forms.Platform.Android.ResourceManager.GetDrawableByName(descriptor.BundleName);
                if (d > 0)
                {
                    return(AndroidBitmapDescriptorFactory.FromResource(d));
                }
                else
                {
                    return(AndroidBitmapDescriptorFactory.DefaultMarker());
                }

            case BitmapDescriptorType.Stream:
                if (descriptor.Stream.CanSeek && descriptor.Stream.Position > 0)
                {
                    descriptor.Stream.Position = 0;
                }
                return(AndroidBitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(descriptor.Stream)));

            case BitmapDescriptorType.AbsolutePath:
                return(AndroidBitmapDescriptorFactory.FromPath(descriptor.AbsolutePath));

            default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker());
            }
        }
Пример #5
0
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            int iconId = 0;

            switch (descriptor.Id)
            {
            case "tourist":
                iconId = Resource.Drawable.touristPin;
                break;

            case "home":
                iconId = Resource.Drawable.homePin;
                break;
            }
            return(AndroidBitmapDescriptorFactory.FromResource(iconId));
        }
Пример #6
0
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            int resId = 0;

            switch (descriptor.Id)
            {
            case "type2":
                resId = Resource.Drawable.type2;
                break;

            case "type1":
                resId = Resource.Drawable.type1;
                break;
            }

            return(AndroidBitmapDescriptorFactory.FromResource(resId));
        }
Пример #7
0
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            var debrisType   = (EDebrisType)Enum.Parse(typeof(EDebrisType), descriptor.Id);
            var resourceName = $"debris{debrisType.ToString().ToLower()}medium";
            var resId        = Application.Context.Resources.GetIdentifier(resourceName, "drawable", "com.companyname.ESFGaivotas");
            var frameId      = Resource.Drawable.DebrisFrame;

            using (Bitmap frameBitmap = BitmapFactory.DecodeResource(Application.Context.Resources, frameId))
                using (Bitmap baseBitmap = BitmapFactory.DecodeResource(Application.Context.Resources, resId))
                    using (Paint paint = new Paint(PaintFlags.AntiAlias))
                    {
                        Bitmap resultBitmap = Bitmap.CreateBitmap(frameBitmap, 0, 0, frameBitmap.Width - 1, frameBitmap.Height - 1);
                        Canvas canvas       = new Canvas(resultBitmap);
                        canvas.DrawBitmap(resultBitmap, 0, 0, paint);
                        canvas.DrawBitmap(baseBitmap, baseBitmap.Width / 2, baseBitmap.Height / 2, paint);

                        return(AndroidBitmapDescriptorFactory.FromBitmap(resultBitmap));
                    }
        }
Пример #8
0
        public static NativeBitmapDescriptor ToBitmapDescriptor(this BitmapDescriptor self)
        {
            switch (self.Type)
            {
            case BitmapDescriptorType.Default:
                return(NativeBitmapDescriptorFactory.DefaultMarker((float)self.Color.Hue * 360f));

            case BitmapDescriptorType.Bundle:
                return(NativeBitmapDescriptorFactory.FromAsset(self.BundleName));

            case BitmapDescriptorType.Stream:
                return(NativeBitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(self.Stream)));

            case BitmapDescriptorType.AbsolutePath:
                return(NativeBitmapDescriptorFactory.FromPath(self.AbsolutePath));

            default:
                return(NativeBitmapDescriptorFactory.DefaultMarker());
            }
        }
        public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            switch (descriptor.Type)
            {
            case BitmapDescriptorType.Default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker((float)((descriptor.Color.Hue * 360f) % 360f)));

            case BitmapDescriptorType.Bundle:
                return(AndroidBitmapDescriptorFactory.FromAsset(descriptor.BundleName));

            case BitmapDescriptorType.Stream:
                if (descriptor.Stream.CanSeek && descriptor.Stream.Position > 0)
                {
                    descriptor.Stream.Position = 0;
                }
                return(AndroidBitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(descriptor.Stream)));

            case BitmapDescriptorType.AbsolutePath:
                return(AndroidBitmapDescriptorFactory.FromPath(descriptor.AbsolutePath));

            default:
                return(AndroidBitmapDescriptorFactory.DefaultMarker());
            }
        }