public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
        {
            switch (descriptor.Id)
            {
            case "wasabee_player_marker":
                return(CreateMarker(Resource.Drawable.wasabee_player_marker));

            case "wasabee_player_marker_self":
                return(CreateMarker(Resource.Drawable.wasabee_player_marker_self));

            case "wasabee_player_marker_gray":
                return(CreateMarker(Resource.Drawable.wasabee_player_marker_gray));
            }

            if (descriptor.Id.Contains('|'))
            {
                var descriptors = descriptor.Id.Split('|');

                var iconId = descriptors[0] switch
                {
                    "DestroyPortalAlert" => descriptors[1] switch
                    {
                        "pending" => Resource.Drawable.wasabee_markers_destroy_pending,
                        "acknowledged" => Resource.Drawable.wasabee_markers_destroy_acknowledged,
                        "completed" => Resource.Drawable.wasabee_markers_destroy_completed,
                        "assigned" => Resource.Drawable.wasabee_markers_destroy_assigned,
                        _ => throw new ArgumentOutOfRangeException(descriptors[1])
                    },
Esempio n. 2
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());
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 移动位置
        /// </summary>
        /// <param name="coordinate"></param>
        public void AnimateTo(Coordinate coordinate)
        {
            this.mapView.Map.Clear();

            var point = new LatLng(coordinate.Latitude, coordinate.Longitude);

            //Title="雪花啤酒(西安)分公司",Lat=34.364438,Lng=108.941338
            //创建当前位置Marker图标
            BitmapDescriptor bitmap = BitmapDescriptorFactory.FromResource(Resource.Drawable.red_location);
            //构建MarkerOption,用于在地图上添加Marker
            OverlayOptions option = new MarkerOptions()
                                    .InvokePosition(point)
                                    .Anchor(0.5f, 0.5f)
                                    .ScaleX(0.5f)
                                    .ScaleY(0.5f)
                                    .Draggable(true)
                                    .InvokeIcon(bitmap);

            ////在地图上添加Marker,并显示
            this.mapView.Map.AddOverlay(option);


            //使地图移动到当前位置
            MapStatus mMapStatus = new MapStatus.Builder()
                                   .Target(point)
                                   .Zoom(18)
                                   .Build();

            //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
            MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.NewMapStatus(mMapStatus);

            //改变地图状态
            this.mapView.Map.SetMapStatus(mMapStatusUpdate);
        }
Esempio n. 4
0
        public void Refresh(List <Option> points)
        {
            this.mapView.Map.Clear();
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            foreach (var point in points)
            {
                var latLng = new LatLng(point.Lat, point.Lng);
                builder = builder.Include(latLng);
                BitmapDescriptor bitmap = BitmapDescriptorFactory.FromResource(Resource.Drawable.red_location);
                //构建MarkerOption,用于在地图上添加Marker
                OverlayOptions option = new MarkerOptions()
                                        .InvokePosition(latLng)
                                        .InvokeTitle(point.Title)
                                        .Anchor(0.5f, 0.5f)
                                        .Draggable(true)
                                        .ScaleX(0.5f)
                                        .ScaleY(0.5f)
                                        .InvokeIcon(bitmap);

                ////在地图上添加Marker,并显示
                this.mapView.Map.AddOverlay(option);
            }

            LatLngBounds    latlngBounds = builder.Build();
            MapStatusUpdate u            = MapStatusUpdateFactory.NewLatLngBounds(latlngBounds, mapView.Width, mapView.Height);

            mapView.Map.AnimateMapStatus(u);
        }
Esempio n. 5
0
        private BitmapDescriptor GetIconByCategory(int i_CategoriesCode)
        {
            BitmapDescriptor icon = null;

            if ((i_CategoriesCode & (int)eCategories.General) != 0)
            {
                icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.General);
            }
            else if ((i_CategoriesCode & (int)eCategories.Food) != 0)
            {
                icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.Food);
            }
            else if ((i_CategoriesCode & (int)eCategories.Sport) != 0)
            {
                icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.Sport);
            }
            else if ((i_CategoriesCode & (int)eCategories.History) != 0)
            {
                icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.History);
            }
            else if ((i_CategoriesCode & (int)eCategories.Nature) != 0)
            {
                icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.Nature);
            }

            return(icon);
        }
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            try
            {
                var place = Autocomplete.GetPlaceFromIntent(data);
                //getting location of the searched place
                var loc = place.LatLng;

                //creating camera update options to move camera to the searched location
                CameraUpdate cam = CameraUpdateFactory.NewLatLngZoom(loc, 17);

                //create marker options
                MarkerOptions markerOption = new MarkerOptions();
                markerOption.SetPosition(loc);
                markerOption.Draggable(true);
                int id0 = (int)typeof(Resource.Drawable).GetField("locationpoint").GetValue(null);
                BitmapDescriptor bmd0 = BitmapDescriptorFactory.FromResource(id0);
                markerOption.SetIcon(bmd0);
                //googleMap.Clear();
                googleMap.AddMarker(markerOption);
                googleMap.MoveCamera(cam);
                googleMap.MarkerDragEnd += GoogleMap_MarkerDragEnd1;
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 7
0
        public static BitmapImage ToBitmapDescriptor(this BitmapDescriptor self)
        {
            switch (self.Type)
            {
            case BitmapDescriptorType.Default:
                //Intercepted in Pushpin.cs to render using Xamarin.Forms contentTemplate
                return(new BitmapImage());

            case BitmapDescriptorType.Bundle:
                return(new BitmapImage(new Uri(String.Format("ms-appx:///{0}", self.BundleName))));

            case BitmapDescriptorType.Stream:
                var bitmap       = new BitmapImage();
                var memoryStream = new MemoryStream();
                self.Stream.CopyTo(memoryStream);
                memoryStream.Position = 0;
                bitmap.SetSource(memoryStream.AsRandomAccessStream());
                return(bitmap);

            case BitmapDescriptorType.AbsolutePath:
                return(new BitmapImage(new Uri(self.AbsolutePath)));

            default:
                //Hopefully shouldnt hit this
                return(new BitmapImage());
            }
        }
Esempio n. 8
0
        public void DrawArrow(LatLng StartLocation, LatLng EndLocation)
        {
            if (mMarker != null)
            {
                mMarker.Remove();
            }

            matrix = new Matrix();

            if (EndLocation != null && StartLocation != null)
            {
                var Deg = CalcBearing(StartLocation, EndLocation);
                matrix.PostRotate(float.Parse(Deg.ToString()));
                bmRotate = Bitmap.CreateBitmap(bmArrow, 0, 0, bmArrow.Width, bmArrow.Height, matrix, true);

                bmDescriptor = BitmapDescriptorFactory.FromBitmap(bmRotate);

                mkOptions = new MarkerOptions();
                mkOptions.SetIcon(bmDescriptor);
                mkOptions.SetPosition(StartLocation);
                mkOptions.Anchor(0.5f, 0.5f);
                mMarker = map.AddMarker(mkOptions);

                bmRotate.Recycle();
                bmRotate = null;

                ////groundOverlayOptions = new GroundOverlayOptions()
                //groundOverlayOptions = new GroundOverlayOptions()
                //    .Position(StartLocation, bmArrow.Width, bmArrow.Height)
                //    .InvokeImage(bmDescriptor)
                //    .InvokeZIndex(5);
                //myOverlay = map.AddGroundOverlay(groundOverlayOptions);
                //ListArrow.Add(myOverlay);
            }
        }
Esempio n. 9
0
 public void Draw(IEnumerable <LatLng> Positions, BitmapDescriptor Icon = null, object Metadata = null)
 {
     foreach (var p in Positions)
     {
         Draw(p, Icon, Metadata);
     }
 }
        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());
            }
        }
Esempio n. 11
0
 public CustomMapRenderer()
 {
     _tempMarkers = new List <CustomMarkerOptions>();
     _pinIcon     = BitmapDescriptorFactory.FromResource(NormalResource);
     _fromPinIcon = BitmapDescriptorFactory.FromResource(FromResource);
     _toPinIcon   = BitmapDescriptorFactory.FromResource(ToResource);
 }
Esempio n. 12
0
        protected override Marker CreateNativeItem(Pin item)
        {
            MarkerOptions options = new MarkerOptions()
                                    .InvokePosition(item.Coordinate.ToNative())
                                    .InvokeTitle(item.Title);

            if (item.Animate)
            {
                options.InvokeAnimateType(MarkerOptions.MarkerAnimateType.Grow);
            }

            options.Draggable(item.Draggable);
            options.Flat(!item.Enabled3D);

            BitmapDescriptor bitmap = item.Image?.ToNative();

            if (null == bitmap)
            {
                throw new Exception("必须提供一个图标");
            }
            options.InvokeIcon(bitmap);

            Marker marker = (Marker)NativeMap.Map.AddOverlay(options);

            item.NativeObject = marker;

            return(marker);
        }
Esempio n. 13
0
        private void AddColorsToMarkers(GeoJsonLayer layer)
        {
            // Iterate over all the features stored in the layer
            foreach (GeoJsonFeature feature in layer.Features.ToEnumerable())
            {
                // Check if the magnitude property exists
                if (feature.GetProperty("mag") != null && feature.HasProperty("place"))
                {
                    double magnitude = Double.Parse(feature.GetProperty("mag"));

                    // Get the icon for the feature
                    BitmapDescriptor pointIcon = BitmapDescriptorFactory.DefaultMarker(MagnitudeToColor(magnitude));

                    // Create a new point style
                    GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();

                    // Set options for the point style
                    pointStyle.Icon    = pointIcon;
                    pointStyle.Title   = "Magnitude of " + magnitude;
                    pointStyle.Snippet = "Earthquake occured " + feature.GetProperty("place");

                    // Assign the point style to the feature
                    feature.PointStyle = pointStyle;
                }
            }
        }
Esempio n. 14
0
        public UIImage ToUIImage(BitmapDescriptor descriptor)
        {
            switch (descriptor.Type)
            {
            case BitmapDescriptorType.Default:
                return(Google.Maps.Marker.MarkerImage(descriptor.Color.ToUIColor()));

            case BitmapDescriptorType.Bundle:
                return(UIImage.FromBundle(descriptor.BundleName));

            case BitmapDescriptorType.Resource:
                return(UIImage.FromBundle(descriptor.BundleName));

            case BitmapDescriptorType.Stream:
                descriptor.Stream.Position = 0;
                // Resize to screen scale
                return(UIImage.LoadFromData(NSData.FromStream(descriptor.Stream), UIScreen.MainScreen.Scale));

            case BitmapDescriptorType.AbsolutePath:
                return(UIImage.FromFile(descriptor.AbsolutePath));

            default:
                return(Google.Maps.Marker.MarkerImage(UIColor.Red));
            }
        }
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = base.CreateMarker(pin);

            if (!(pin is CustomPin))
            {
                return(marker);
            }
            if (((CustomPin)(pin)).type == CustomPin.MOVABLE)
            {
                marker.Draggable(true);
                marker.SetRotation(30.5f);
                BitmapDescriptor ic = BitmapDescriptorFactory.FromResource(Resource.Drawable.Target);

                marker.SetIcon(ic);
                marker.Anchor(0.5f, 0.5f);
            }
            else if (((CustomPin)(pin)).type == CustomPin.HOLE)
            {
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.flag));
            }
            else if (((CustomPin)(pin)).type == CustomPin.USER)
            {
            }
            else if (((CustomPin)(pin)).type == CustomPin.LOCKED)
            {
                marker.SetRotation(30.5f);
                marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
            }


            return(marker);
        }
Esempio n. 16
0
        private void AddMarker()
        {
            if (_currentLocation != null)
            {
                RunOnUiThread(() =>
                {
                    if (_marker != null)
                    {
                        _marker.Remove();
                    }
                    LatLng latlngnew      = new LatLng(_currentLocation.Latitude, _currentLocation.Longitude);
                    BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.marker);

                    MarkerOptions markerOption = new MarkerOptions()
                                                 .SetPosition(latlngnew)
                                                 .SetIcon(icon);
                    _marker = gmap.AddMarker(markerOption);
                    //BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)
                    if (i == 0)
                    {
                        gmap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(latlngnew, 19.0f));
                        i++;
                    }
                });
            }
        }
        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());
            }
        }
Esempio n. 18
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));
        }
Esempio n. 19
0
        private void SetInProgressOrdersMarker(OrderSalepoint order)
        {
            if (order.EndLatLng == null || this.inprogressOrdersMarkers.ContainsKey(order.Id))
            {
                return;
            }

            MarkerOptions options = new MarkerOptions();
            MarkerTag     tag     = new MarkerTag {
                OrderId = order.Id
            };

            tag.Type = MarkerType.InProgressOrder;

            BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.marker);

            options.SetIcon(icon);

            string title = string.Concat(order.DestinationCity, ", ", order.DestinationAddress);

            options.SetTitle(title);
            options.SetPosition(new LatLng(order.EndLatLng.lat, order.EndLatLng.lng));

            this.activity.RunOnUiThread(() =>
            {
                Marker marker = this.map.AddMarker(options);
                marker.Tag    = tag;
                inprogressOrdersMarkers.Add(order.Id, marker);
            });
        }
Esempio n. 20
0
        private BitmapDescriptor GetPinIcon(PinType type)
        {
            if (type == PinType.Generic)
            {
                if (UserPin != null)
                {
                    return(UserPin);
                }

                var drawableResource = Context.Resources.GetDrawable("UserLocation.png");
                UserPin = BitmapDescriptorFactory.FromBitmap(((BitmapDrawable)drawableResource).Bitmap);
                return(UserPin);
            }
            else
            {
                if (WasherPin != null)
                {
                    return(WasherPin);
                }

                var drawableResource = Context.Resources.GetDrawable("CitoPin.png");
                WasherPin = BitmapDescriptorFactory.FromBitmap(((BitmapDrawable)drawableResource).Bitmap);
                return(WasherPin);
            }
        }
Esempio n. 21
0
        //updates the markers and route
        public void updateUI()
        {
            BitmapDescriptor truck    = BitmapDescriptorFactory.FromResource(Resource.Drawable.truck);
            BitmapDescriptor finisher = BitmapDescriptorFactory.FromResource(Resource.Drawable.finisher);

            map.Clear();

            //temp variable -> no chance of changes in foreach
            List <PartnerVehicle> listtemp = partnerlist;

            Log.Debug("updateUI", "list of partners");

            foreach (PartnerVehicle aPartnerVehicle in listtemp)
            {
                aPartnerVehicle.display();
                //add polylines from all vehicles to map
                map.AddPolyline(aPartnerVehicle.getPolylineOptions());
                //add markers and set positions
                MarkerOptions markerpartner = new MarkerOptions();
                markerpartner.SetPosition(aPartnerVehicle.getLocation());
                if (truckbool == false)
                {
                    //truckmarker
                    markerpartner.SetIcon(truck);
                    markerpartner.SetTitle("Truck " + aPartnerVehicle.getid() + " arrives in: " + aPartnerVehicle.getDur() + "s");
                }
                else
                {
                    //finisher marker
                    markerpartner.SetIcon(finisher);
                    markerpartner.SetTitle("Arriving at Finisher " + aPartnerVehicle.getid() + "in: " + aPartnerVehicle.getDur() + "s");
                }
                map.AddMarker(markerpartner);
            }
        }
Esempio n. 22
0
        private async Task HandleGroundOverlayForTile(TileInfo tileInfo)
        {
            if (SharedOverlay.IsVisible)
            {
                int       virtualTileSize = Extensions.SKMapExtensions.MercatorMapSize >> tileInfo.Zoom;
                int       xPixelsStart    = tileInfo.X * virtualTileSize;
                int       yPixelsStart    = tileInfo.Y * virtualTileSize;
                double    zoomScale       = SKMapCanvas.MapTileSize / (double)virtualTileSize;
                Rectangle mercatorSpan    = new Rectangle(xPixelsStart, yPixelsStart, virtualTileSize, virtualTileSize);
                SKMapSpan tileSpan        = mercatorSpan.ToGps();

                if (tileSpan.FastIntersects(SharedOverlay.GpsBounds))
                {
                    SKBitmap         bitmap                  = DrawTileToBitmap(tileSpan, zoomScale);
                    BitmapDescriptor bitmapDescriptor        = BitmapDescriptorFactory.FromBitmap(bitmap.ToBitmap());
                    TaskCompletionSource <object> drawingTcs = new TaskCompletionSource <object>();

                    Console.WriteLine($"Refreshing ground tile at ({tileInfo.X}, {tileInfo.Y}) for zoom level {tileInfo.Zoom} ({zoomScale}) with GPS bounds {tileSpan}");

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        GroundOverlay overlay;

                        lock (_GroundOverlays)
                        {
                            overlay = _GroundOverlays.FirstOrDefault(o => (o.Tag as TileInfo)?.Equals(tileInfo) ?? false);
                        }

                        if (overlay == null)
                        {
                            GroundOverlayOptions overlayOptions = new GroundOverlayOptions().PositionFromBounds(tileSpan.ToLatLng())
                                                                  .InvokeImage(bitmapDescriptor);

                            overlay     = _NativeMap.AddGroundOverlay(overlayOptions);
                            overlay.Tag = tileInfo;

                            lock (_GroundOverlays)
                            {
                                _GroundOverlays.Add(overlay);
                            }
                        }
                        else if ((overlay.Tag as TileInfo)?.NeedsRedraw ?? false)
                        {
                            overlay.SetImage(bitmapDescriptor);
                        }

                        drawingTcs.TrySetResult(null);
                    });

                    await drawingTcs.Task.ConfigureAwait(false);

                    ReleaseOverlayBitmap(bitmap);
                }
                else
                {
                    Console.WriteLine($"Ground tile at ({tileInfo.X}, {tileInfo.Y}) for zoom level {tileInfo.Zoom} already exists");
                }
            }
        }
Esempio n. 23
0
 public CustomMapRenderer(Context context) : base(context)
 {
     _tempMarkers = new List <CustomMarkerOptions>();
     _pinIcon     = BitmapDescriptorFactory.FromResource(NormalResource);
     _fromPinIcon = BitmapDescriptorFactory.FromResource(FromResource);
     _toPinIcon   = BitmapDescriptorFactory.FromResource(ToResource);
     this.context = context;
 }
Esempio n. 24
0
            protected override void OnBeforeClusterItemRendered(Java.Lang.Object item, MarkerOptions markerOptions)
            {
                var clusterItem = item.JavaCast <MyItem>();

                BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(GetResourceForPin(clusterItem.IconType));

                markerOptions.SetIcon(icon).SetTitle(clusterItem.Title);
            }
    protected override IBitmapList DrawCore(IBitmapList bitmaps)
    {
        if (Options.Scale.Descriptors.Count < 1)
        {
            return(bitmaps);
        }

        var scaleBitmaps     = new BitmapList();
        var watermarkBitmaps = new BitmapList();

        foreach (var bitmap in bitmaps)
        {
            var realBitmap = (SKBitmap)bitmap.Source;
            // 遍历缩放信息
            foreach (var scaleDescriptor in Options.Scale.Descriptors)
            {
                // 如果源图尺寸小于缩放尺寸,则跳过当前缩放信息
                if (realBitmap.Width <= scaleDescriptor.MaxSize.Width &&
                    realBitmap.Height <= scaleDescriptor.MaxSize.Height)
                {
                    continue;
                }

                // 计算等比例缩放尺寸
                var imageSize = new Size(realBitmap.Width, realBitmap.Height);
                var scaleSize = ImageHelper.ScaleSize(imageSize, scaleDescriptor.MaxSize);
                var scaleInfo = new SKImageInfo(scaleSize.Width, scaleSize.Height,
                                                realBitmap.Info.ColorType, realBitmap.Info.AlphaType);

                // 是否附加缩放尺寸后缀
                var scaleNameFuffix = scaleDescriptor.FileNameSuffix;
                if (Options.Scale.AddScaleSizeSuffix)
                {
                    scaleNameFuffix += $"-{scaleSize.Width}x{scaleSize.Height}";
                }

                // 创建缩放位图描述符
                var scaleBitmap = realBitmap.Resize(scaleInfo, Options.ResizeQuality);
                var descriptor  = new BitmapDescriptor(scaleBitmap, bitmap.FilePath,
                                                       scaleNameFuffix);

                scaleBitmaps.Add(descriptor);

                if (scaleDescriptor.AddWatermark)
                {
                    watermarkBitmaps.Add(descriptor);
                }
            }
        }

        // 处理缩放位图集合的水印
        if (watermarkBitmaps.Count > 0)
        {
            _watermarkDrawer.Draw(watermarkBitmaps);
        }

        return(scaleBitmaps);
    }
Esempio n. 26
0
 public void SetIcon(View view)
 {
     if (null != mBeijing)
     {
         Bitmap           bitmap           = BitmapFactory.DecodeResource(Resources, Resource.Drawable.badge_tr);
         BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.FromBitmap(bitmap);
         mBeijing.SetIcon(bitmapDescriptor);
     }
 }
Esempio n. 27
0
        void GetLocationss()
        {
            WebService webService = new WebService();
            var        Donus      = webService.OkuGetir("locations");

            if (Donus != null)
            {
                var aa = Donus.ToString();
                Locationss = Newtonsoft.Json.JsonConvert.DeserializeObject <List <HaritaListeDataModel> >(Donus.ToString());
                if (Locationss.Count > 0)
                {
                    //Locationss.ForEach(item => item.coordinateX = 40.9932879);
                    //Locationss.ForEach(item => item.coordinateY = 29.1506936);
                    this.Activity.RunOnUiThread(() => {
                        for (int i = 0; i < Locationss.Count; i++)
                        {
                            MapUtils mapUtils = new MapUtils();
                            Android.Graphics.Bitmap bitmap = mapUtils.createStoreMarker(this.Activity, false);

                            BitmapDescriptor image = BitmapDescriptorFactory.FromBitmap(bitmap);

                            if (_map != null)
                            {
                                MarkerOptions markerOpt1 = new MarkerOptions();
                                markerOpt1.SetPosition(new LatLng(Locationss[i].coordinateX, Locationss[i].coordinateY));
                                markerOpt1.SetTitle(i.ToString());
                                markerOpt1.SetIcon(image);
                                //markerOpt1.Visible(MapDataModel1[i].IsShow);
                                var EklenenMarker = _map.AddMarker(markerOpt1);
                                //MapDataModel1[i].IlgiliMarker = EklenenMarker;
                            }
                        }

                        if (Locationss.Count > 0)
                        {
                            ListeyiFragmentCagir();
                            CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(new LatLng(StartLocationCall.UserLastLocation.Latitude, StartLocationCall.UserLastLocation.Longitude), 20);
                            _map.MoveCamera(cameraUpdate);
                        }
                        ShowLoading.Hide();
                    });
                }
                else
                {
                    AlertHelper.AlertGoster("Popüler lokasyon bulunamadı...", this.Activity);
                    ShowLoading.Hide();
                }
            }
            else
            {
                ShowLoading.Hide();
            }
            this.Activity.RunOnUiThread(delegate()
            {
                GelenBase1.ButonKullanimDuzenle(true);
            });
        }
Esempio n. 28
0
        private GroundOverlay SobreporMapaComImagem(LatLng geoPosition, BitmapDescriptor bitmapDescriptor, float width, float heigth)
        {
            //LatLng NEWARK = new LatLng(-23.312847, -51.1448709);
            //BitmapDescriptorFactory.FromResource(Resource.Drawable.Icon)
            GroundOverlayOptions newarkMap = new GroundOverlayOptions()
                                             .InvokeImage(bitmapDescriptor).Position(geoPosition, width, heigth);

            return(GMap.AddGroundOverlay(newarkMap));
        }
Esempio n. 29
0
        private MarkerOptions CreateStopMarker(BitmapDescriptor bitmapDescriptor, params Stop[] stops)
        {
            Stop stop = stops[0];

            return(new MarkerOptions()
                   .SetPosition(new LatLng(stops.Average(s => s.Position.Latitude), stops.Average(s => s.Position.Longitude)))
                   .SetIcon(bitmapDescriptor)
                   .SetTitle(stop.Name)
                   .Anchor(0.5f, 0.5f));
        }
        private Marker AddNewMarkerToMap(MapFragment mapFragment, LatLng position, BitmapDescriptor icon)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(position);
            marker.InvokeIcon(icon);

            var actualMarker = mapFragment.Map.AddMarker(marker);

            return(actualMarker);
        }