コード例 #1
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();

            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            TextView textView = new TextView(context);

            textView.TextSize = 16;
            textView.SetPadding(10, 20, 0, 0);
            textView.SetHeight(90);

            textView.Text = "Top 40 countries population";
            layout.AddView(textView);
            textView.Gravity = Android.Views.GravityFlags.Top;
            maps             = new SfMaps(context);

            ShapeFileLayer layer = new ShapeFileLayer();

            layer.ShowItems         = true;
            layer.Uri               = "world1.shp";
            layer.DataSource        = GetDataSource();
            layer.ShapeIdPath       = "Country";
            layer.ShowItems         = true;
            layer.ShapeIdTableField = "NAME";

            layer.ShapeSettings           = new ShapeSetting();
            layer.ShapeSettings.ShapeFill = Color.LightGray;

            BubbleMarkerSetting marker = new BubbleMarkerSetting();

            marker.ValuePath      = "Population";
            marker.ColorValuePath = "Population";

            BubbleCustomTooltipSetting tooltipSetting = new BubbleCustomTooltipSetting(context);

            tooltipSetting.ShowTooltip = true;
            tooltipSetting.ValuePath   = "Country";
            marker.TooltipSettings     = tooltipSetting;

            RangeColorMapping rangeColorMapping = new RangeColorMapping();

            rangeColorMapping.Color       = Color.ParseColor("#2E769F");
            rangeColorMapping.To          = 1400000000;
            rangeColorMapping.From        = 325000000;
            rangeColorMapping.LegendLabel = "Above 4%";
            marker.ColorMapping.Add(rangeColorMapping);

            RangeColorMapping rangeColorMapping1 = new RangeColorMapping();

            rangeColorMapping1.Color       = Color.ParseColor("#D84444");
            rangeColorMapping1.To          = 325000000;
            rangeColorMapping1.From        = 180000000;
            rangeColorMapping1.LegendLabel = "4% - 2%";
            marker.ColorMapping.Add(rangeColorMapping1);

            RangeColorMapping rangeColorMapping2 = new RangeColorMapping();

            rangeColorMapping2.Color       = Color.ParseColor("#816F28");
            rangeColorMapping2.To          = 180000000;
            rangeColorMapping2.From        = 100000000;
            rangeColorMapping2.LegendLabel = "2% - 1%";
            marker.ColorMapping.Add(rangeColorMapping2);

            RangeColorMapping rangeColorMapping3 = new RangeColorMapping();

            rangeColorMapping3.Color       = Color.ParseColor("#7F38A0");
            rangeColorMapping3.To          = 100000000;
            rangeColorMapping3.From        = 5000000;
            rangeColorMapping3.LegendLabel = "Below 1%";
            marker.ColorMapping.Add(rangeColorMapping3);

            layer.BubbleMarkerSetting = marker;

            LegendSetting legendSetting = new LegendSetting();

            legendSetting.ShowLegend          = true;
            legendSetting.LegendType          = LegendType.Bubbles;
            legendSetting.IconHeight          = 15;
            legendSetting.IconWidth           = 15;
            legendSetting.LegendPosition      = new Point(50, 5);
            legendSetting.HorizontalAlignment = HorizontalAlignment.Center;
            layer.LegendSetting = legendSetting;

            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });
            handler.PostDelayed(run, 100);

            return(layout);
        }
コード例 #2
0
        public BubbleVisualization ()
        {
            
            SFMap maps = new SFMap ();
            view = new UIView ();
            view.Frame=new CGRect(0,0,300,400);
            busyindicator = new SfBusyIndicator();
            busyindicator.ViewBoxWidth=75;
            busyindicator.ViewBoxHeight=75;
            busyindicator.Foreground=  UIColor.FromRGB (0x77, 0x97, 0x72);  /*#779772*/
            busyindicator.AnimationType=SFBusyIndicatorAnimationType.SFBusyIndicatorAnimationTypeSlicedCircle;
            view.AddSubview (busyindicator);
            label = new UILabel ();
            label.TextAlignment = UITextAlignment.Center;
            label.Text = "Top 40 Population Countries With Bubbles";
			label.Font = UIFont.SystemFontOfSize (18);
			label.Frame=new  CGRect(0,0,400,40);
			label.TextColor = UIColor.Black;
			view.AddSubview (label);

			NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0.3), delegate {
                if (isDisposed)
                    return;
				maps.Frame = new CGRect(Frame.Location.X,60,Frame.Size.Width-6,Frame.Size.Height-60);

				view.AddSubview (maps);
			});

			SFShapeFileLayer layer = new SFShapeFileLayer ();
            layer.Uri = (NSString)NSBundle.MainBundle.PathForResource("world1", "shp");
            layer.ShapeIDPath = (NSString)"Country";
            layer.ShapeIDTableField = (NSString)"NAME";
            layer.ShowMapItems = true;
			layer.DataSource = GetDataSource();

			SFShapeSetting shapeSettings = new SFShapeSetting ();
            shapeSettings.Fill = UIColor.LightGray;
			layer.ShapeSettings = shapeSettings;
			
            SFBubbleMarkerSetting marker = new SFBubbleMarkerSetting();
            marker.ValuePath = (NSString)"Percent";
            marker.ColorValuePath = (NSString)"Percent";

            BubbleCustomTooltipSetting tooltipSetting = new BubbleCustomTooltipSetting();
            tooltipSetting.ShowTooltip = true;
            marker.TooltipSettings = tooltipSetting;

            ObservableCollection<SFMapColorMapping> colorMappings = new ObservableCollection<SFMapColorMapping>();

            SFRangeColorMapping rangeColorMapping1 = new SFRangeColorMapping();
            rangeColorMapping1.To = 20;
            rangeColorMapping1.From = 4;
            rangeColorMapping1.LegendLabel = (NSString)"Above 4%";
            rangeColorMapping1.Color = UIColor.FromRGB(46, 118, 159);
            colorMappings.Add(rangeColorMapping1);

            SFRangeColorMapping rangeColorMapping2 = new SFRangeColorMapping();
            rangeColorMapping2.To = 4;
            rangeColorMapping2.From = 2;
            rangeColorMapping2.LegendLabel = (NSString)"4% - 2%";
            rangeColorMapping2.Color = UIColor.FromRGB(216, 68, 68);
            colorMappings.Add(rangeColorMapping2);

            SFRangeColorMapping rangeColorMapping3 = new SFRangeColorMapping();
            rangeColorMapping3.To = 2;
            rangeColorMapping3.From = 1;
            rangeColorMapping3.LegendLabel = (NSString)"2% - 1%";
            rangeColorMapping3.Color = UIColor.FromRGB(129, 111, 40);
            colorMappings.Add(rangeColorMapping3);

            SFRangeColorMapping rangeColorMapping4 = new SFRangeColorMapping();
            rangeColorMapping4.To = 1;
            rangeColorMapping4.From = 0;
            rangeColorMapping4.LegendLabel = (NSString)"Below 1%";
            rangeColorMapping4.Color = UIColor.FromRGB(127, 56, 160);
            colorMappings.Add(rangeColorMapping4);

            marker.ColorMappings = colorMappings;
           
			layer.BubbleMarkerSetting = marker;

            SFMapLegendSettings mapLegendSettings = new SFMapLegendSettings();
            mapLegendSettings.ShowLegend = true;
            mapLegendSettings.LegendType = LegendType.Bubbles;
           
            layer.LegendSettings = mapLegendSettings;

			maps.Layers.Add (layer);
			

            label2 = new UILabel();
            label2.TextAlignment = UITextAlignment.Center;
            var text1 = new NSString("en.wikipedia.org");
            label2.Text = text1;
            label2.Font = UIFont.SystemFontOfSize(12);
            var stringAtribute = new NSDictionary(UIStringAttributeKey.Font, label2.Font,
                                                  UIStringAttributeKey.ForegroundColor, UIColor.FromRGB(0, 191, 255));
            UIStringAttributes strAtr1 = new UIStringAttributes(stringAtribute);
            label2Size = text1.GetSizeUsingAttributes(strAtr1);
            label2.TextColor = UIColor.FromRGB(0, 191, 255);
            label2.Frame = new CGRect(Frame.Size.Width, Frame.Size.Height - 20, 100, 20);
            label2.UserInteractionEnabled = true;
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer();
            tapGesture.ShouldReceiveTouch += TapGesture_ShouldReceiveTouch;
            label2.AddGestureRecognizer(tapGesture);

            view.AddSubview(label2);

            AddSubview (view);
            maps.Delegate = new MapsBubbleDelegate (this);

        }