Example #1
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);

        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.


            SFTreeMap treeMap = new SFTreeMap();

            treeMap.WeightValuePath = (NSString)"Population";
            treeMap.ColorValuePath  = (NSString)"Growth";

            SFLeafItemSetting leafItemSetting = new SFLeafItemSetting();

            leafItemSetting.Gap         = 2;
            leafItemSetting.LabelPath   = (NSString)"Region";
            leafItemSetting.BorderColor = UIColor.FromRGB(169, 217, 247);
            leafItemSetting.ShowLabels  = true;
            treeMap.LeafItemSettings    = leafItemSetting;

            SFTreeMapFlatLevel flatLevel = new SFTreeMapFlatLevel();

            flatLevel.GroupBorderColor = UIColor.Gray;
            flatLevel.GroupBorderWidth = 1;
            flatLevel.GroupBackground  = UIColor.White;
            flatLevel.HeaderHeight     = 20;
            flatLevel.GroupPath        = (NSString)"Continent";
            flatLevel.GroupGap         = 5;
            flatLevel.HeaderStyle      = new SFStyle()
            {
                Color = UIColor.Black
            };
            flatLevel.ShowHeader = true;
            treeMap.Levels.Add(flatLevel);

            SFLegendSetting legendSetting = new SFLegendSetting();

            legendSetting.ShowLegend = true;
            legendSetting.Size       = new CoreGraphics.CGSize(500, 45);
            treeMap.LegendSettings   = legendSetting;


            SFRangeColorMapping colorMapping = new SFRangeColorMapping();

            SFRange range1 = new SFRange();

            range1.LegendLabel = (NSString)"1 % Growth";
            range1.From        = 0;
            range1.To          = 1;
            range1.Color       = UIColor.FromRGB(119, 216, 216);

            SFRange range2 = new SFRange();

            range2.LegendLabel = (NSString)"2 % Growth";
            range2.From        = 0;
            range2.To          = 2;
            range2.Color       = UIColor.FromRGB(174, 217, 96);

            SFRange range3 = new SFRange();

            range3.LegendLabel = (NSString)"3 % Growth";
            range3.From        = 0;
            range3.To          = 3;
            range3.Color       = UIColor.FromRGB(255, 175, 81);

            SFRange range4 = new SFRange();

            range4.LegendLabel = (NSString)"4 % Growth";
            range4.From        = 0;
            range4.To          = 4;
            range4.Color       = UIColor.FromRGB(243, 210, 64);

            colorMapping.Ranges.Add(range1);
            colorMapping.Ranges.Add(range2);
            colorMapping.Ranges.Add(range3);
            colorMapping.Ranges.Add(range4);

            treeMap.LeafItemColorMapping = colorMapping;


            GetPopulationData();
            treeMap.DataSource  = PopulationDetails;
            treeMap.ShowTooltip = true;
            treeMap.Frame       = new CoreGraphics.CGRect(View.Frame.Left, View.Frame.Top + 50, View.Frame.Width, View.Frame.Height - 100);

            this.View.AddSubview(treeMap);
        }
        public BubbleVisualization()
        {
            maps       = new SFMap();
            view       = new UIView();
            view.Frame = new CGRect(0, 0, 300, 400);

            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);


            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";

            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);
        }
Example #4
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
            {
                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)"Population";
            marker.ColorValuePath = (NSString)"Population";

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

            SFRangeColorMapping rangeColorMapping1 = new SFRangeColorMapping();

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

            SFRangeColorMapping rangeColorMapping2 = new SFRangeColorMapping();

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

            SFRangeColorMapping rangeColorMapping3 = new SFRangeColorMapping();

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

            SFRangeColorMapping rangeColorMapping4 = new SFRangeColorMapping();

            rangeColorMapping4.To          = 100000000;
            rangeColorMapping4.From        = 5000000;
            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;
            mapLegendSettings.IconSize   = new CGSize(15, 15);
            mapLegendSettings.Position   = new CGPoint(50, 5);
            mapLegendSettings.TextSize   = 15;
            layer.LegendSettings         = mapLegendSettings;

            maps.Layers.Add(layer);
            AddSubview(view);
            maps.Delegate = new MapsBubbleDelegate(this);
        }