Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        protected override Marker CreateNativeItem(Pin item)
        {
            //var options = new MarkerOptions().InvokePosition(item.Coordinate.ToNative()).InvokeTitle(item.Title);

            MarkerOptions options = new MarkerOptions().InvokePosition(item.Coordinate.ToNative());

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

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

            BitmapDescriptor bitmap = BitmapDescriptorFactory.FromResource(Resource.Drawable.water_drop);

            //BitmapDescriptor bitmap = item.Image?.ToNative();
            if (null == bitmap)
            {
                throw new Exception("必须提供一个图标");
            }
            //var nbitmap = ScaleBitmap(bitmap.Bitmap, 0.5f);
            //TextOptions textOptions = new TextOptions();
            //textOptions.InvokeText(item.Title);
            //textOptions.InvokePosition(item.Coordinate.ToNative());

            options.InvokeIcon(bitmap);

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

            marker.Scale      = 0.5f;
            marker.Title      = item.Title;
            item.NativeObject = marker;

            return(marker);
        }