User Tools

Site Tools


source_code_androideditionsample_visualization.zip

Source Code AndroidEditionSample Visualization.zip

MainActivity.cs

 using Android.App;  
 using Android.Content;  
 using Android.OS;  
 using Android.Widget;  
 using System;  
 using System.Collections.ObjectModel;  
 using System.Linq;  
 using System.Reflection;  
 using System.Xml.Linq;  
 
 namespace AnalyzingVisualization  
 {  
     [Activity(Label|= "Analyze Visual", Icon = "@drawable/icon", ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.KeyboardHidden | Android.Content.PM.ConfigChanges.ScreenSize)]  
     public class MainActivity : Activity  
     {  
         private BaseSample currentSample;  
         private ListView sampleListView;  
         private SliderView sampleListContainer;  
         private Collection<BaseSample> samples;  
 
         protected override void OnCreate(Bundle bundle)  
         {  
             base.OnCreate(bundle);  
             SetContentView(Resource.Layout.Main);  
             ActionBar.Hide();  
 
             sampleListView = FindViewById<ListView>(Resource.Id.listView);  
             sampleListContainer = (SliderView)FindViewById(Resource.Id.slider_view);  
 
             InitializeSampleListView();  
 
             currentSample = samples.FirstOrDefault();  
             currentSample.UpdateSampleLayout();  
             sampleListContainer.MainView.AddView(currentSample.SampleView);  
 
             FindViewById<ImageButton>(Resource.Id.sampleListMoreButton).Click += OnMoreButtonClick;  
         }  
 
         private void InitializeSampleListView()  
         {  
             samples = new Collection<BaseSample>();  
             XDocument xDoc = XDocument.Load(Assets.Open("SampleList.xml"));  
             if (xDoc.Root != null)  
             {  
                 foreach (var element in xDoc.Root.Elements())  
                 {  
                     string image = element.Attribute("Image").Value;  
                     string className = element.Attribute("Class").Value;  
                     string name = element.Attribute("Name").Value;  
 
                     BaseSample sample = (BaseSample)Activator.CreateInstance(Assembly.GetExecutingAssembly().GetType("AnalyzingVisualization." + className), this);  
                     sample.Title = name;  
                     sample.ImageId = (int)typeof(Resource.Drawable).GetField(image).GetValue(null);  
                     sample.SampleListButtonClick += (s, e) => sampleListContainer.SetSlided(!sampleListContainer.IsSlided());  
 
                     samples.Add(sample);  
                 }  
             }  
 
             ActivityListItemAdapter adapter = new ActivityListItemAdapter(this, samples);  
             sampleListView.Adapter = adapter;  
             sampleListView.ItemClick += SampleListViewItemClick;  
         }  
 
         private void SampleListViewItemClick(object sender, AdapterView.ItemClickEventArgs e)  
         {  
             currentSample.DisposeMap();  
             currentSample = samples[e.Position];  
             currentSample.UpdateSampleLayout();  
 
             sampleListContainer.SetSlided(false);  
             sampleListContainer.MainView.RemoveAllViews();  
             sampleListContainer.MainView.AddView(currentSample.SampleView);  
         }  
 
         private void OnMoreButtonClick(object sender, EventArgs eventArgs)  
         {  
             Intent helpIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("http://www.thinkgeo.com"));  
             StartActivity(helpIntent);  
         }  
     }  
 }  
 

SplashActivity.cs

 using Android.App;  
 using Android.OS;  
 using Android.Widget;  
 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.IO;  
 using System.Linq;  
 using System.Threading.Tasks;  
 
 namespace AnalyzingVisualization  
 {  
     [Activity(Theme|= "@android:style/Theme.Light.NoTitleBar", MainLauncher = true, NoHistory = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait,  
         ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.KeyboardHidden |  
         Android.Content.PM.ConfigChanges.ScreenSize)]  
     public class SplashActivity : Activity  
     {  
         private TextView uploadTextView;  
         private ProgressBar uploadProgressBar;  
 
         protected override void OnCreate(Bundle savedInstanceState)  
         {  
             base.OnCreate(savedInstanceState);  
             SetContentView(Resource.Layout.SplashLayout);  
 
             uploadTextView = FindViewById<TextView>(Resource.Id.uploadDataTextView);  
             uploadProgressBar = FindViewById<ProgressBar>(Resource.Id.uploadProgressBar);  
 
             Task updateSampleDatasTask = Task.Factory.StartNew(() =>  
             {  
                 Collection<string> unLoadDatas = CollectUnloadDatas(SampleHelper.SampleDataDictionary, SampleHelper.AssetsDataDictionary);  
                 UploadDataFiles(SampleHelper.SampleDataDictionary, unLoadDatas, OnCopyingSourceFile);  
 
                 uploadTextView.Post(() =>  
                 {  
                     uploadTextView.Text = "Ready";  
                     uploadProgressBar.Progress = 100;  
                 });  
             });  
 
             updateSampleDatasTask.ContinueWith(t =>  
             {  
                 uploadTextView.PostDelayed(() =>  
                 {  
                     StartActivity(typeof(MainActivity));  
                     Finish();  
                 }, 200);  
             });  
         }  
 
         private void OnCopyingSourceFile(string targetPathFilename, int completeCount, int totalCount)  
         {  
             uploadTextView.Post(() =>  
             {  
                 uploadTextView.Text = string.Format("Copying {0} ({1}/{2})", Path.GetFileName(targetPathFilename), completeCount, totalCount);  
                 uploadProgressBar.Progress = (int)(completeCount * 100f / totalCount);  
             });  
         }  
 
         private Collection<string> CollectUnloadDatas(string targetDirectory, string sourceDirectory)  
         {  
             Collection<string> result = new Collection<string>();  
 
             foreach (string filename in Assets.List(sourceDirectory))  
             {  
                 string sourcePath = System.IO.Path.Combine(sourceDirectory, filename);  
                 string targetPath = System.IO.Path.Combine(targetDirectory, sourcePath);  
 
                 bool isSourcePathAFile = !string.IsNullOrEmpty(Path.GetExtension(sourcePath));  
                 if (isSourcePathAFile && !File.Exists(targetPath))  
                 {  
                     result.Add(sourcePath);  
                 }  
                 else if (!isSourcePathAFile)  
                 {  
                     foreach (string item in CollectUnloadDatas(targetDirectory, sourcePath))  
                     {  
                         result.Add(item);  
                     }  
                 }  
             }  
             return result;  
         }  
 
         private void UploadDataFiles(string targetDirectory, IEnumerable<string> sourcePathFilenames, Action<string, int, int> onCopyingSourceFile = null)  
         {  
             int completeCount = 0;  
             if (!Directory.Exists(targetDirectory)) Directory.CreateDirectory(targetDirectory);  
 
             foreach (string sourcePathFilename in sourcePathFilenames)  
             {  
                 string targetPathFilename = Path.Combine(targetDirectory, sourcePathFilename);  
                 if (!File.Exists(targetPathFilename))  
                 {  
                     if (onCopyingSourceFile != null) onCopyingSourceFile(targetPathFilename, completeCount, sourcePathFilenames.Count());  
 
                     string targetPath = Path.GetDirectoryName(targetPathFilename);  
                     if (!Directory.Exists(targetPath)) Directory.CreateDirectory(targetPath);  
                     Stream sourceStream = Assets.Open(sourcePathFilename);  
                     FileStream fileStream = File.Create(targetPathFilename);  
                     sourceStream.CopyTo(fileStream);  
                     fileStream.Close();  
                     sourceStream.Close();  
 
                     completeCount++;  
                 }  
             }  
         }  
     }  
 }  
 

AssemblyInfo.cs

 using System.Reflection;  
 using System.Runtime.CompilerServices;  
 using System.Runtime.InteropServices;  
 using Android.App;  
 
 // General Information about an assembly is controlled through the following  
 // set of attributes. Change these attribute values to modify the information  
 // associated with an assembly.  
 [assembly:|AssemblyTitle("AnalyzingVisualization")]  
 [assembly: AssemblyDescription("")]  
 [assembly:|AssemblyConfiguration("")]  
 [assembly: AssemblyCompany("")]  
 [assembly:|AssemblyProduct("AnalyzingVisualization")]  
 [assembly: AssemblyCopyright("Copyright ©  2014")]  
 [assembly:|AssemblyTrademark("")]  
 [assembly: AssemblyCulture("")]  
 [assembly:|ComVisible(false)]  
 
 // Version information for an assembly consists of the following four values:  
 //  
 //      Major Version  
 //      Minor Version  
 //      Build Number  
 //      Revision  
 //  
 // You can specify all the values or you can default the Build and Revision Numbers  
 // by using the '*' as shown below:  
 // [assembly:|AssemblyVersion("1.0.*")]  
 [assembly: AssemblyVersion("1.0.0.0")]  
 [assembly:|AssemblyFileVersion("1.0.0.0")]  
 
 

Resource.Designer.cs

 #pragma warning disable 1591  
 //------------------------------------------------------------------------------  
 // <auto-generated>  
 //     This code was generated by a tool.  
 //     Runtime Version:4.0.30319.0  
 //  
 //     Changes to this file may cause incorrect behavior and will be lost if  
 //     the code is regenerated.  
 // </auto-generated>  
 //------------------------------------------------------------------------------  
 
 [assembly:|global::Android.Runtime.ResourceDesignerAttribute("AnalyzingVisualization.Resource", IsApplication=true)]  
 
 namespace AnalyzingVisualization  
 {  
 
 
 	[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks",|"1.0.0.0")]  
 	public partial class Resource  
 	{  
 
 		static Resource()  
 		{  
 			global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 		}  
 
 		public static void UpdateIdValues()  
 		{  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_default256x256 = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_default256x256;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_default512x512 = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_default512x512;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_globe;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe_Pressed = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_globe_Pressed;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_Minus;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus_Pressed = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_Minus_Pressed;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_noImageTile = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_noImageTile;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_Plus;  
 			global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus_Pressed = global::AnalyzingVisualization.Resource.Drawable.icon_mapsuite_Plus_Pressed;  
 		}  
 
 		public partial class Animation  
 		{  
 
 			// aapt resource value: 0x7f040000  
 			public const int bottomViewIn = 2130968576;  
 
 			// aapt resource value: 0x7f040001  
 			public const int bottomViewOut = 2130968577;  
 
 			static Animation()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private Animation()  
 			{  
 			}  
 		}  
 
 		public partial class Attribute  
 		{  
 
 			static Attribute()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private Attribute()  
 			{  
 			}  
 		}  
 
 		public partial class Drawable  
 		{  
 
 			// aapt resource value: 0x7f020000  
 			public const int classbreak = 2130837504;  
 
 			// aapt resource value: 0x7f020001  
 			public const int clusterstyle = 2130837505;  
 
 			// aapt resource value: 0x7f020002  
 			public const int customstyle = 2130837506;  
 
 			// aapt resource value: 0x7f020003  
 			public const int detail40 = 2130837507;  
 
 			// aapt resource value: 0x7f020004  
 			public const int dotdensity = 2130837508;  
 
 			// aapt resource value: 0x7f020005  
 			public const int filterstyle = 2130837509;  
 
 			// aapt resource value: 0x7f020006  
 			public const int graySettings40 = 2130837510;  
 
 			// aapt resource value: 0x7f020007  
 			public const int heatmap = 2130837511;  
 
 			// aapt resource value: 0x7f020008  
 			public const int Icon = 2130837512;  
 
 			// aapt resource value: 0x7f020009  
 			public const int icon_mapsuite_default256x256 = 2130837513;  
 
 			// aapt resource value: 0x7f02000a  
 			public const int icon_mapsuite_default512x512 = 2130837514;  
 
 			// aapt resource value: 0x7f02000b  
 			public const int icon_mapsuite_globe = 2130837515;  
 
 			// aapt resource value: 0x7f02000c  
 			public const int icon_mapsuite_globe_Pressed = 2130837516;  
 
 			// aapt resource value: 0x7f02000d  
 			public const int icon_mapsuite_Minus = 2130837517;  
 
 			// aapt resource value: 0x7f02000e  
 			public const int icon_mapsuite_Minus_Pressed = 2130837518;  
 
 			// aapt resource value: 0x7f02000f  
 			public const int icon_mapsuite_noImageTile = 2130837519;  
 
 			// aapt resource value: 0x7f020010  
 			public const int icon_mapsuite_Plus = 2130837520;  
 
 			// aapt resource value: 0x7f020011  
 			public const int icon_mapsuite_Plus_Pressed = 2130837521;  
 
 			// aapt resource value: 0x7f020012  
 			public const int iconstyle = 2130837522;  
 
 			// aapt resource value: 0x7f020013  
 			public const int isoline = 2130837523;  
 
 			// aapt resource value: 0x7f020014  
 			public const int MapSuite = 2130837524;  
 
 			// aapt resource value: 0x7f020015  
 			public const int More = 2130837525;  
 
 			// aapt resource value: 0x7f020016  
 			public const int more40 = 2130837526;  
 
 			// aapt resource value: 0x7f020017  
 			public const int settings40 = 2130837527;  
 
 			// aapt resource value: 0x7f020018  
 			public const int SliderLineBackground = 2130837528;  
 
 			static Drawable()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private Drawable()  
 			{  
 			}  
 		}  
 
 		public partial class Id  
 		{  
 
 			// aapt resource value: 0x7f060013  
 			public const int LabelStylingLayout = 2131099667;  
 
 			// aapt resource value: 0x7f060017  
 			public const int MapContainerView = 2131099671;  
 
 			// aapt resource value: 0x7f060014  
 			public const int SampleListButton = 2131099668;  
 
 			// aapt resource value: 0x7f060016  
 			public const int SettingsButton = 2131099670;  
 
 			// aapt resource value: 0x7f060015  
 			public const int TitleTextView = 2131099669;  
 
 			// aapt resource value: 0x7f06000d  
 			public const int applyButton = 2131099661;  
 
 			// aapt resource value: 0x7f060004  
 			public const int columnLinearLayour = 2131099652;  
 
 			// aapt resource value: 0x7f060005  
 			public const int columnTextView = 2131099653;  
 
 			// aapt resource value: 0x7f060007  
 			public const int conditionLinearLayour = 2131099655;  
 
 			// aapt resource value: 0x7f060009  
 			public const int conditionSpinner = 2131099657;  
 
 			// aapt resource value: 0x7f060008  
 			public const int conditionextView = 2131099656;  
 
 			// aapt resource value: 0x7f060001  
 			public const int headerLinearLayout = 2131099649;  
 
 			// aapt resource value: 0x7f060010  
 			public const int listView = 2131099664;  
 
 			// aapt resource value: 0x7f060012  
 			public const int mainLinearLayout = 2131099666;  
 
 			// aapt resource value: 0x7f060003  
 			public const int moreImageButton = 2131099651;  
 
 			// aapt resource value: 0x7f060006  
 			public const int nameTextView = 2131099654;  
 
 			// aapt resource value: 0x7f060011  
 			public const int sampleListMoreButton = 2131099665;  
 
 			// aapt resource value: 0x7f06000f  
 			public const int sampleListTitle = 2131099663;  
 
 			// aapt resource value: 0x7f060002  
 			public const int settingTextView = 2131099650;  
 
 			// aapt resource value: 0x7f060000  
 			public const int settingsLinearLayout = 2131099648;  
 
 			// aapt resource value: 0x7f06000e  
 			public const int slider_view = 2131099662;  
 
 			// aapt resource value: 0x7f060019  
 			public const int uploadDataTextView = 2131099673;  
 
 			// aapt resource value: 0x7f060018  
 			public const int uploadProgressBar = 2131099672;  
 
 			// aapt resource value: 0x7f06000c  
 			public const int valueEditText = 2131099660;  
 
 			// aapt resource value: 0x7f06000a  
 			public const int valueLinearLayour = 2131099658;  
 
 			// aapt resource value: 0x7f06000b  
 			public const int valueTextView = 2131099659;  
 
 			static Id()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private Id()  
 			{  
 			}  
 		}  
 
 		public partial class Layout  
 		{  
 
 			// aapt resource value: 0x7f030000  
 			public const int ButtonBackgroundSelector = 2130903040;  
 
 			// aapt resource value: 0x7f030001  
 			public const int FilterStyleSettings = 2130903041;  
 
 			// aapt resource value: 0x7f030002  
 			public const int Main = 2130903042;  
 
 			// aapt resource value: 0x7f030003  
 			public const int SampleBaseLayout = 2130903043;  
 
 			// aapt resource value: 0x7f030004  
 			public const int SampleSpinnerCheckedText = 2130903044;  
 
 			// aapt resource value: 0x7f030005  
 			public const int SplashLayout = 2130903045;  
 
 			static Layout()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private Layout()  
 			{  
 			}  
 		}  
 
 		public partial class String  
 		{  
 
 			// aapt resource value: 0x7f050001  
 			public const int ApplicationName = 2131034113;  
 
 			// aapt resource value: 0x7f050000  
 			public const int Hello = 2131034112;  
 
 			static String()  
 			{  
 				global::Android.Runtime.ResourceIdManager.UpdateIdValues();  
 			}  
 
 			private String()  
 			{  
 			}  
 		}  
 	}  
 }  
 #pragma warning restore 1591  
 
 

DotDenstyStyleSample.cs

 using Android.Content;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class DotDenstyStyleSample : BaseSample  
     {  
         public DotDenstyStyleSample(Context context)  
             : base(context)  
         { }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-128.455625, 88.474096875, -65.174375, -9.084496875);  
 
             ShapeFileFeatureLayer usLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usStatesCensus2010.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(usLayer);  
             MapView.Overlays.Add(layerOverlay);  
 
             usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();  
             usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new AreaStyle(new GeoPen(new GeoSolidBrush(GeoColor.SimpleColors.Black))));  
 
             double pointToValueRatio = 0.0000094778167166538189;  
             PointStyle pointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Black, 7);  
             DotDensityStyle dotDensityStyle = new DotDensityStyle("Population", pointToValueRatio, pointStyle);  
             dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromHtml("#a57431"), 5);  
 
             usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(dotDensityStyle);  
             usLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
     }  
 }  
 

HeatStyleSample.cs

 using Android.Content;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class HeatStyleSample : BaseSample  
     {  
         public HeatStyleSample(Context context)  
             : base(context)  
         { }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-124.097208477811, 48.9471097666172, -110.242106301448, 28.7359794668483);  
 
             ShapeFileFeatureLayer usEarthquakeLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usEarthquake_Simplified.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(usEarthquakeLayer);  
             MapView.Overlays.Add(layerOverlay);  
 
             usEarthquakeLayer.DrawingMarginPercentage = 100;  
             usEarthquakeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();  
             usEarthquakeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new HeatStyle(10, 150, "MAGNITUDE", 0, 12, 100, DistanceUnit.Kilometer));  
             usEarthquakeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
     }  
 }  
 

IconStyleSample.cs

 using Android.Content;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class IconStyleSample : BaseSample  
     {  
         public IconStyleSample(Context context)  
             : base(context)  
         { }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-96.8924, 33.3525, -96.6453, 32.9714);  
 
             ShapeFileFeatureLayer iconStyleFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("Vehicles.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(iconStyleFeatureLayer);  
             MapView.Overlays.Add(layerOverlay);  
 
             iconStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();  
             iconStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(GetIconStyle(SampleHelper.GetDataPath(@"Images/")));  
             iconStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
 
         private static ValueStyle GetIconStyle(string imagePath)  
         {  
             ValueStyle valueStyle = new ValueStyle();  
             valueStyle.ColumnName = "TYPE";  
 
             GeoFont font = new GeoFont("Arial", 9);  
             GeoSolidBrush brush = new GeoSolidBrush(GeoColor.StandardColors.Black);  
 
             valueStyle.ValueItems.Add(new ValueItem("1", new IconStyle(imagePath + "vehicle1.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("2", new IconStyle(imagePath + "vehicle2.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("3", new IconStyle(imagePath + "vehicle3.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("4", new IconStyle(imagePath + "vehicle4.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("5", new IconStyle(imagePath + "vehicle5.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("6", new IconStyle(imagePath + "vehicle6.png", "Type", font, brush)));  
             valueStyle.ValueItems.Add(new ValueItem("7", new IconStyle(imagePath + "vehicle7.png", "Type", font, brush)));  
 
             return valueStyle;  
         }  
     }  
 }  
 

BaseSample.cs

 using Android.App;  
 using Android.Content;  
 using Android.Graphics;  
 using Android.Util;  
 using Android.Views;  
 using Android.Widget;  
 using System;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public abstract class BaseSample  
     {  
         private MapView mapView;  
         private View sampleView;  
         private TextView titleTextView;  
         private ImageButton settingsButton;  
         public EventHandler<EventArgs> SampleListButtonClick;  
 
         public BaseSample(Context context)  
         {  
             sampleView = View.Inflate(context, Resource.Layout.SampleBaseLayout, null);  
             titleTextView = sampleView.FindViewById<TextView>(Resource.Id.TitleTextView);  
             settingsButton = sampleView.FindViewById<ImageButton>(Resource.Id.SettingsButton);  
             settingsButton.Click += (s, e) => ApplySettings();  
             sampleView.FindViewById<ImageButton>(Resource.Id.SampleListButton).Click += OnSampleListButtonClick;  
         }  
 
         public string Title  
         {  
             get { return titleTextView.Text; }  
             set { titleTextView.Text = value; }  
         }  
 
         public int ImageId { get; set; }  
 
         /// <summary>  
         /// This is map view, if it doesn't exist, we will create one.  
         /// </summary>  
         protected MapView MapView  
         {  
             get { return mapView ?? (mapView = new MapView(Application.Context)); }  
         }  
 
         /// <summary>  
         /// This is a container for a concrete sample. Including map and corresponding components for interaction.  
         /// </summary>  
         public View SampleView  
         {  
             get { return sampleView; }  
         }  
 
         /// <summary>  
         /// This method updates the sample layout; including creating new map with default themes.  
         /// </summary>  
         public void UpdateSampleLayout()  
         {  
             try  
             {  
                 FrameLayout mapContainerView = sampleView.FindViewById<FrameLayout>(Resource.Id.MapContainerView);  
                 mapContainerView.RemoveAllViews();  
 
                 mapView = new MapView(Application.Context);  
                 mapView.SetBackgroundColor(Color.Argb(255, 244, 242, 238));  
                 mapContainerView.AddView(mapView);  
 
                 InitializeBackgroundMap();  
                 InitializeMap();  
             }  
             catch (Exception ex)  
             {  
                 Log.Debug("Sample Changed", ex.Message);  
             }  
 
             // Customize the sample layout with specific sample.  
             UpdateSampleLayoutCore();  
         }  
 
         /// <summary>  
         /// Allows user to customize the sample layout.  
         /// </summary>  
         protected virtual void UpdateSampleLayoutCore()  
         { }  
 
         /// <summary>  
         /// Disposes the map view.  
         /// It is necessary to dispose the map resources when current sample is changed to avoid the OOM issue.  
         /// </summary>  
         public void DisposeMap()  
         {  
             if (mapView != null && mapView.Parent != null)  
             {  
                 FrameLayout mapContainerView = sampleView.FindViewById<FrameLayout>(Resource.Id.MapContainerView);  
                 mapContainerView.RemoveAllViews();  
 
                 mapView.Dispose();  
                 mapView = null;  
                 GC.Collect();  
                 GC.WaitForPendingFinalizers();  
             }  
         }  
 
         /// <summary>  
         /// This method customizes the map for a specific sample.  
         /// We could add overlays, layers, styles inside of this method.  
         /// </summary>  
         protected abstract void InitializeMap();  
 
         /// <summary>  
         /// Applies the settings when clicked the settings apply button.  
         /// </summary>  
         protected virtual void ApplySettings()  
         { }  
 
         protected virtual void OnSampleListButtonClick(object sender, EventArgs e)  
         {  
             EventHandler<EventArgs> handler = SampleListButtonClick;  
             if (handler != null) handler(this, e);  
         }  
 
         /// <summary>  
         /// Initalizes the base map for the MapView.  
         /// </summary>  
         private void InitializeBackgroundMap()  
         {  
             if (!MapView.Overlays.Contains("WMK"))  
             {  
                 WorldMapKitOverlay worldOverlay = new WorldMapKitOverlay();  
                 worldOverlay.TileType = TileType.MultiTile;  
                 worldOverlay.Projection = WorldMapKitProjection.DecimalDegrees;  
 
                 string baseFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;  
                 string cachePathFilename = System.IO.Path.Combine(baseFolder, "MapSuiteTileCaches/SampleCaches.db");  
                 worldOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "DecimalDegrees");  
                 MapView.Overlays.Insert(0, "WMK", worldOverlay);  
             }  
         }  
     }  
 }  
 

ClassBreakChartView.cs

 using Android.Content;  
 using Android.Graphics;  
 using Android.Text;  
 using Android.Util;  
 using Android.Views;  
 using System.Linq;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class ClassBreakChartView : View  
     {  
         private float paddingTop;  
         private float paddingLeft;  
         private float paddingRight;  
         private float paddingBottom;  
         private float segmentWidth;  
         private float segmentHeight;  
         private float textMargin;  
         private float maxTextWidth;  
 
         private float offsetX;  
         private float offsetY;  
 
         private TextPaint textPaint;  
         private ClassBreakStyle classBreakStyle;  
 
         public ClassBreakChartView(Context context, ClassBreakStyle classBreakStyle)  
             : this(context, null, classBreakStyle)  
         {  
         }  
 
         public ClassBreakChartView(Context context, IAttributeSet attrs, ClassBreakStyle classBreakStyle)  
             : base(context, attrs)  
         {  
             this.classBreakStyle = classBreakStyle;  
             this.Alpha = .9f;  
 
             float ratio = context.Resources.DisplayMetrics.Density;  
             paddingTop = 2 * ratio;  
             paddingLeft = 2 * ratio;  
             paddingRight = 2 * ratio;  
             paddingBottom = 2 * ratio;  
             segmentWidth = 40 * ratio;  
             segmentHeight = 20 * ratio;  
             textMargin = 4 * ratio;  
 
             textPaint = new TextPaint();  
             textPaint.Color = Color.Black;  
             textPaint.AntiAlias = true;  
             textPaint.TextSize = 9 * ratio;  
 
             maxTextWidth = classBreakStyle.ClassBreaks.Select(c => MeasureText(c.Value.ToString("R0"), textPaint).Width).Max();  
             offsetX = 5 * ratio;  
             offsetY = -5 * ratio;  
         }  
 
         public override void Draw(Canvas canvas)  
         {  
             float width = paddingLeft + segmentWidth + paddingRight;  
             float height = paddingTop + segmentHeight * classBreakStyle.ClassBreaks.Count + paddingBottom;  
 
             Paint backgroundPaint = new Paint();  
             backgroundPaint.Color = Color.White;  
             backgroundPaint.SetStyle(Paint.Style.Fill);  
             canvas.DrawRect(new RectF(offsetX, offsetY + (Height - height), offsetX + width, offsetY + Height), backgroundPaint);  
 
             Paint segmentPaint = new Paint();  
             segmentPaint.SetStyle(Paint.Style.Fill);  
 
             TextPaint haloTextPaint = new TextPaint();  
             haloTextPaint.Color = Color.White;  
             haloTextPaint.SetStyle(Paint.Style.Stroke);  
             haloTextPaint.StrokeWidth = 2;  
             haloTextPaint.AntiAlias = true;  
             haloTextPaint.TextSize = textPaint.TextSize;  
 
             for (int i = 0; i < classBreakStyle.ClassBreaks.Count; i++)  
             {  
                 int currentIndex = i;  
                 float barLeft = offsetX + paddingLeft;  
                 float barTop = offsetY + Height - (paddingBottom + (i + 1) * segmentHeight);  
                 float barRight = barLeft + segmentWidth;  
                 float barBottom = barTop + segmentHeight;  
 
                 segmentPaint.Color = GetColor(classBreakStyle.ClassBreaks[currentIndex]);  
                 canvas.DrawRect(new RectF(barLeft, barTop, barRight, barBottom), segmentPaint);  
 
                 float x = barRight + paddingRight + textMargin;  
                 float y = barTop + segmentHeight / 2 + textPaint.TextSize / 2;  
 
                 canvas.DrawText(classBreakStyle.ClassBreaks[currentIndex].Value.ToString("R0"), x, y, haloTextPaint);  
                 canvas.DrawText(classBreakStyle.ClassBreaks[currentIndex].Value.ToString("R0"), x, y, textPaint);  
             }  
         }  
 
         private static Color GetColor(ClassBreak classBreak)  
         {  
             GeoColor color = classBreak.DefaultAreaStyle.FillSolidBrush.Color;  
             return new Color(color.RedComponent, color.GreenComponent, color.BlueComponent, color.AlphaComponent);  
         }  
 
         private DrawingRectangleF MeasureText(string text, Paint paint)  
         {  
             Paint textPaint = paint;  
             Rect bounds = new Rect();  
             textPaint.GetTextBounds(text != " " ? text : "a", 0, text.Length, bounds);  
 
             float width = bounds.Right - bounds.Left;  
             float height = bounds.Bottom - bounds.Top;  
             return new DrawingRectangleF(width / 2, height / 2, width, height);  
         }  
     }  
 }  
 

ClassBreakStyleSample.cs

 using Android.App;  
 using Android.Content;  
 using Android.Widget;  
 using System.Collections.ObjectModel;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class ClassBreakStyleSample : BaseSample  
     {  
         private ClassBreakStyle classBreakStyle;  
 
         public ClassBreakStyleSample(Context context)  
             : base(context)  
         {  
         }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-128.455625, 88.474096875, -65.174375, -9.084496875);  
 
             ShapeFileFeatureLayer usLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usStatesCensus2010.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(usLayer);  
             MapView.Overlays.Add(layerOverlay);  
 
             classBreakStyle = GetClassBreakStyle();  
             usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();  
             usLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);  
             usLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
 
         protected override void UpdateSampleLayoutCore()  
         {  
             FrameLayout mapContainerView = SampleView.FindViewById<FrameLayout>(Resource.Id.MapContainerView);  
             ClassBreakChartView classBreakChartView = new ClassBreakChartView(Application.Context, classBreakStyle);  
             mapContainerView.AddView(classBreakChartView);  
         }  
 
         private static ClassBreakStyle GetClassBreakStyle()  
         {  
             double[] classBreakValues = { 0, 814180.0, 1328361.0, 2059179.0, 2967297.0, 4339367.0, 5303925.0, 6392017.0, 8791894.0 };  
 
             GeoColor outlineColor = GeoColor.FromHtml("#f05133");  
             GeoColor fromColor = GeoColor.FromArgb(255, 116, 160, 255);  
             GeoColor toColor = GeoColor.FromArgb(255, 220, 52, 56);  
             Collection<GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(fromColor, toColor, 10, ColorWheelDirection.CounterClockwise);  
             ClassBreakStyle style = new ClassBreakStyle("Population", BreakValueInclusion.IncludeValue);  
             for (int i = 0; i < classBreakValues.Length; i++)  
             {  
                 style.ClassBreaks.Add(new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(200, familyColors[i]), outlineColor, 1)));  
             }  
 
             return style;  
         }  
     }  
 }  
 

ClassBreakClusterPointStyle.cs

 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.Globalization;  
 using System.Linq;  
 using System.Reflection;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     [Serializable]  
     public class ClassBreakClusterPointStyle : Style  
     {  
         [Obfuscation(Exclude|= true)]  
         private Dictionary<int, PointStyle> classBreakPoint;  
 
         [Obfuscation(Exclude|= true)]  
         private int cellSize = 100;  
 
         [Obfuscation(Exclude|= true)]  
         private TextStyle textSytle = new TextStyle();  
 
         public ClassBreakClusterPointStyle()  
             : base()  
         {  
             classBreakPoint = new Dictionary<int, PointStyle>();  
         }  
 
         public Dictionary<int, PointStyle> ClassBreakPoint  
         {  
             get { return classBreakPoint; }  
         }  
 
         public TextStyle TextStyle  
         {  
             get { return textSytle; }  
             set { textSytle = value; }  
         }  
 
         public int CellSize  
         {  
             get { return cellSize; }  
             set { cellSize = value; }  
         }  
 
         protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             double scale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, canvas.MapUnit);  
             MapSuiteTileMatrix mapSuiteTileMatrix = new MapSuiteTileMatrix(scale, cellSize, cellSize, canvas.MapUnit);  
             IEnumerable<TileMatrixCell> tileMatricCells = mapSuiteTileMatrix.GetContainedCells(canvas.CurrentWorldExtent);  
             Dictionary<string, string> unusedFeatures = new Dictionary<string, string>();  
 
             foreach (Feature feature in features)  
             {  
                 if (feature.GetWellKnownType() != WellKnownType.Point && feature.GetWellKnownType() != WellKnownType.Multipoint)  
                 {  
                     continue;  
                 }  
                 unusedFeatures.Add(feature.Id, feature.Id);  
             }  
 
             foreach (TileMatrixCell cell in tileMatricCells)  
             {  
                 int featureCount = 0;  
                 MultipointShape tempMultiPointShape = new MultipointShape();  
                 foreach (Feature feature in features)  
                 {  
                     // Make sure the feature has not been used in another cluster  
                     if (unusedFeatures.ContainsKey(feature.Id))  
                     {  
                         // Check if the cell contains the feature  
                         if (cell.BoundingBox.Contains(feature.GetBoundingBox()))  
                         {  
                             featureCount++;  
                             unusedFeatures.Remove(feature.Id);  
                             if (feature.GetWellKnownType() == WellKnownType.Multipoint)  
                             {  
                                 MultipointShape multipointShape = feature.GetShape() as MultipointShape;  
                                 foreach (var item in multipointShape.Points)  
                                 {  
                                     tempMultiPointShape.Points.Add(item);  
                                 }  
                             }  
                             else  
                             {  
                                 tempMultiPointShape.Points.Add(feature.GetShape() as PointShape);  
                             }  
                         }  
                     }  
                 }  
                 if (featureCount > 0)  
                 {  
                     // Add the feature count to the new feature we created.  The feature will be placed  
                     // at the center of gravity of all the clustered features of the cell we created.  
                     Dictionary<string, string> featureValues = new Dictionary<string, string>();  
                     featureValues.Add("FeatureCount", featureCount.ToString(CultureInfo.InvariantCulture));  
 
                     bool isMatch = false;  
 
                     for (int i = 0; i < classBreakPoint.Count - 1; i++)  
                     {  
                         var startItem = classBreakPoint.ElementAt(i);  
                         var endItem = classBreakPoint.ElementAt(i + 1);  
                         if (featureCount >= startItem.Key && featureCount < endItem.Key)  
                         {  
                             //Draw the point shape  
                             startItem.Value.Draw(new[] { new Feature(tempMultiPointShape.GetCenterPoint(), featureValues) }, canvas, labelsInThisLayer, labelsInAllLayers);  
                             isMatch = true;  
                             break;  
                         }  
                     }  
                     if (!isMatch && featureCount >= classBreakPoint.LastOrDefault().Key)  
                     {  
                         classBreakPoint.LastOrDefault().Value.Draw(new[] { new Feature(tempMultiPointShape.GetCenterPoint(), featureValues) }, canvas, labelsInThisLayer, labelsInAllLayers);  
                     }  
 
                     if (featureCount != 1)  
                     {  
                         // Draw the text style to show how many feaures are consolidated in the cluster  
                         textSytle.Draw(new[] { new Feature(tempMultiPointShape.GetCenterPoint(), featureValues) }, canvas, labelsInThisLayer, labelsInAllLayers);  
                     }  
                 }  
             }  
         }  
     }  
 }  
 

ClusterPointStyleSample.cs

 using Android.Content;  
 using Android.Util;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class ClusterPointStyleSample : BaseSample  
     {  
         public ClusterPointStyleSample(Context context)  
             : this(context, null)  
         { }  
 
         public ClusterPointStyleSample(Context context, IAttributeSet attrs)  
             : base(context)  
         {  
         }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-128.455625, 88.474096875, -65.174375, -9.084496875);  
 
             ShapeFileFeatureLayer clusterPointStyleFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("usEarthquake.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(clusterPointStyleFeatureLayer);  
             MapView.Overlays.Add(layerOverlay);  
 
             clusterPointStyleFeatureLayer.DrawingMarginPercentage = 100;  
             clusterPointStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();  
             clusterPointStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(GetClusterPointStyle());  
             clusterPointStyleFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
 
         private static ClassBreakClusterPointStyle GetClusterPointStyle()  
         {  
             ClassBreakClusterPointStyle clusterPointStyle = new ClassBreakClusterPointStyle();  
             clusterPointStyle.CellSize = 65;  
 
             PointStyle pointStyle1 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 222, 226, 153)), new GeoPen(GeoColor.FromArgb(100, 222, 226, 153), 5), 8);  
             clusterPointStyle.ClassBreakPoint.Add(1, pointStyle1);  
 
             PointStyle pointStyle2 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 222, 226, 153)), new GeoPen(GeoColor.FromArgb(100, 222, 226, 153), 8), 15);  
             clusterPointStyle.ClassBreakPoint.Add(2, pointStyle2);  
 
             PointStyle pointStyle3 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 255, 183, 76)), new GeoPen(GeoColor.FromArgb(100, 255, 183, 76), 10), 25);  
             clusterPointStyle.ClassBreakPoint.Add(50, pointStyle3);  
 
             PointStyle pointStyle4 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 243, 193, 26)), new GeoPen(GeoColor.FromArgb(100, 243, 193, 26), 15), 35);  
             clusterPointStyle.ClassBreakPoint.Add(150, pointStyle4);  
 
             PointStyle pointStyle5 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 245, 7, 10)), new GeoPen(GeoColor.FromArgb(100, 245, 7, 10), 15), 40);  
             clusterPointStyle.ClassBreakPoint.Add(350, pointStyle5);  
 
             PointStyle pointStyle6 = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(250, 245, 7, 10)), new GeoPen(GeoColor.FromArgb(100, 245, 7, 10), 20), 50);  
             clusterPointStyle.ClassBreakPoint.Add(500, pointStyle6);  
 
             clusterPointStyle.TextStyle = TextStyles.CreateSimpleTextStyle("FeatureCount", "Arail", 10, DrawingFontStyles.Regular, GeoColor.SimpleColors.Black);  
             clusterPointStyle.TextStyle.PointPlacement = PointPlacement.Center;  
             return clusterPointStyle;  
         }  
     }  
 }  
 

CustomGeoImageLineStyle.cs

 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.Linq;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class CustomGeoImageLineStyle : LineStyle  
     {  
         private Collection<GeoImage> geoImages;  
         private int spacing;  
         private LineStyle lineStyle;  
         private SymbolSide side;  
 
         public CustomGeoImageLineStyle(LineStyle lineStyle, GeoImage geoImage, int spacing, SymbolSide side)  
             : this(lineStyle, new Collection<GeoImage> { geoImage }, spacing, side)  
         { }  
 
         public CustomGeoImageLineStyle(LineStyle lineStyle, IEnumerable<GeoImage> geoImages, int spacing, SymbolSide side)  
         {  
             this.side = side;  
             this.spacing = spacing;  
             this.lineStyle = lineStyle;  
             this.geoImages = new Collection<GeoImage>();  
             foreach (var geoImage in geoImages)  
             {  
                 this.geoImages.Add(geoImage);  
             }  
         }  
 
         protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             PointStyle[] pointStyles = geoImages.Select(geoImage => { return new PointStyle(geoImage) { DrawingLevel = DrawingLevel.LevelThree }; }).ToArray();  
             foreach (Feature feature in features)  
             {  
                 LineShape lineShape = (LineShape)feature.GetShape();  
                 lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);  
 
                 int index = 0;  
                 double totalDist = 0;  
                 for (int i = 0; i < lineShape.Vertices.Count - 1; i++)  
                 {  
                     PointShape pointShape1 = new PointShape(lineShape.Vertices[i]);  
                     PointShape pointShape2 = new PointShape(lineShape.Vertices[i|+ 1]);  
 
                     LineShape tempLineShape = new LineShape();  
                     tempLineShape.Vertices.Add(lineShape.Vertices[i]);  
                     tempLineShape.Vertices.Add(lineShape.Vertices[i|+ 1]);  
 
                     double angle = GetAngleFromTwoVertices(lineShape.Vertices[i], lineShape.Vertices[i|+ 1]);  
 
                     //Left side  
                     if (side == SymbolSide.Left)  
                     {  
                         if (angle >= 270) { angle = angle - 180; }  
                     }  
                     //Right side  
                     else  
                     {  
                         if (angle <= 90) { angle = angle + 180; }  
                     }  
                     //pointStyle.RotationAngle = (float)angle;  
                     foreach (var pointStyle in pointStyles) pointStyle.RotationAngle = (float)angle;  
                     float screenDist = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1,  
                                                                                         pointShape2, canvas.Width, canvas.Height);  
                     double currentDist = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2);  
                     double worldInterval = (currentDist * spacing) / screenDist;  
 
                     while (totalDist <= currentDist)  
                     {  
                         PointStyle pointStyle = pointStyles[index|% pointStyles.Length];  
                         PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDist, canvas.MapUnit, DistanceUnit.Meter);  
                         pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers);  
                         totalDist = totalDist + worldInterval;  
                         index++;  
                     }  
 
                     totalDist = totalDist - currentDist;  
                 }  
             }  
         }  
 
         private double GetAngleFromTwoVertices(Vertex b, Vertex c)  
         {  
             double alpha = 0;  
             double tangentAlpha = (c.Y - b.Y) / (c.X - b.X);  
             double Peta = Math.Atan(tangentAlpha);  
 
             if (c.X > b.X)  
             {  
                 alpha = 90 + (Peta * (180 / Math.PI));  
             }  
             else if (c.X < b.X)  
             {  
                 alpha = 270 + (Peta * (180 / Math.PI));  
             }  
             else  
             {  
                 if (c.Y > b.Y) alpha = 0;  
                 if (c.Y < b.Y) alpha = 180;  
             }  
 
             double offset;  
             if (b.X > c.X)  
             { offset = 90; }  
             else { offset = -90; }  
 
             return alpha + offset;  
         }  
 
         public enum SymbolSide  
         {  
             Right = 0,  
             Left = 1  
         }  
     }  
 }  
 

CustomStyleSample.cs

 using Android.Content;  
 using System;  
 using System.Collections.ObjectModel;  
 using System.Globalization;  
 using System.IO;  
 using System.Linq;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class CustomStyleSample : BaseSample  
     {  
         public CustomStyleSample(Context context)  
             : base(context)  
         { }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.Meter;  
             MapView.CurrentExtent = new RectangleShape(-13886070, 6660597, -8906057, 3382985);  
 
             WorldMapKitOverlay worldOverlay = (WorldMapKitOverlay)MapView.Overlays["WMK"];  
             worldOverlay.Projection = WorldMapKitProjection.SphericalMercator;  
             string baseFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;  
             string cachePathFilename = Path.Combine(baseFolder, "MapSuiteTileCaches/SampleCaches.db");  
             worldOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "SphericalMercator");  
 
             LineStyle lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 50, 0, 249), 4, false);  
 
             //Cold Front  
             CustomGeoImageLineStyle coldFrontLineStyle = GetCustomLineStyle(lineStyle, 19, CustomGeoImageLineStyle.SymbolSide.Right,  
                 SampleHelper.GetDataPath(@"CustomStyles/offset_circle_red_bl.png"), SampleHelper.GetDataPath(@"CustomStyles/offset_triangle_blue_revert.png"));  
 
             InMemoryFeatureLayer inMemoryFeatureLayerColdFront = new InMemoryFeatureLayer();  
             inMemoryFeatureLayerColdFront.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(coldFrontLineStyle);  
             inMemoryFeatureLayerColdFront.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             inMemoryFeatureLayerColdFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/ColdFront2.txt"))));  
             inMemoryFeatureLayerColdFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/ColdFront3.txt"))));  
 
             //Warm Front  
             InMemoryFeatureLayer inMemoryFeatureLayerWarmFront = new InMemoryFeatureLayer();  
             CustomGeoImageLineStyle warmFrontLineStyle = new CustomGeoImageLineStyle(lineStyle, new GeoImage(SampleHelper.GetDataPath(@"CustomStyles/offset_circle_blue.png")),  
                                                                                                     30, CustomGeoImageLineStyle.SymbolSide.Right);  
             inMemoryFeatureLayerWarmFront.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(warmFrontLineStyle);  
             inMemoryFeatureLayerWarmFront.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             inMemoryFeatureLayerWarmFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/WarmFront5.txt"))));  
             inMemoryFeatureLayerWarmFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/WarmFront6.txt"))));  
             inMemoryFeatureLayerWarmFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/WarmFront7.txt"))));  
             inMemoryFeatureLayerWarmFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/WarmFront8.txt"))));  
 
             //Occluded Front  
             InMemoryFeatureLayer inMemoryFeatureLayerOccludedFront = new InMemoryFeatureLayer();  
             CustomGeoImageLineStyle occludedFrontLineStyle = GetCustomLineStyle(lineStyle, 45, CustomGeoImageLineStyle.SymbolSide.Right,  
                 SampleHelper.GetDataPath(@"CustomStyles/offset_triangle_and_circle_blue.png"), SampleHelper.GetDataPath(@"CustomStyles/offset_triangle_and_circle_red.png"));  
             inMemoryFeatureLayerOccludedFront.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(occludedFrontLineStyle);  
             inMemoryFeatureLayerOccludedFront.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             inMemoryFeatureLayerOccludedFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/OccludedFront9.txt"))));  
             inMemoryFeatureLayerOccludedFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/OccludedFront10.txt"))));  
             inMemoryFeatureLayerOccludedFront.InternalFeatures.Add(new Feature(File.ReadAllText(SampleHelper.GetDataPath(@"CustomStyles/OccludedFront11.txt"))));  
 
             PressureValueStyle pressureValueStyle = new PressureValueStyle();  
             pressureValueStyle.ColumnName = "Pressure";  
 
             InMemoryFeatureLayer pressureFeatureLayer = new InMemoryFeatureLayer();  
             pressureFeatureLayer.Open();  
             pressureFeatureLayer.Columns.Add(new FeatureSourceColumn("Pressure"));  
             pressureFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pressureValueStyle);  
             pressureFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             pressureFeatureLayer.InternalFeatures.Add(new Feature(MapView.CurrentExtent.GetCenterPoint()));  
 
             Random random = new Random();  
             string[] pressures = { "H", "L" };  
             for (int i = 0; i < 20; i++)  
             {  
                 Feature pressurePoint = new Feature(random.Next(-13886070, -8906057), random.Next(3382985, 6660597));  
                 pressurePoint.ColumnValues["Pressure"] = pressures[random.Next(0,|2)];  
                 pressureFeatureLayer.InternalFeatures.Add(pressurePoint);  
             }  
 
             WindPointStyle windStyle1 = new WindPointStyle("TEXT", "LEVEL", "ANGLE", GeoColor.FromHtml("#0AF8F8"));  
             WindPointStyle windStyle2 = new WindPointStyle("TEXT", "LEVEL", "ANGLE", GeoColor.FromHtml("#0FF5B0"));  
             WindPointStyle windStyle3 = new WindPointStyle("TEXT", "LEVEL", "ANGLE", GeoColor.FromHtml("#F7F70D"));  
             WindPointStyle windStyle4 = new WindPointStyle("TEXT", "LEVEL", "ANGLE", GeoColor.FromHtml("#FBE306"));  
 
             ClassBreakStyle windClassBreakStyle = new ClassBreakStyle();  
             windClassBreakStyle.ColumnName = "TEXT";  
             windClassBreakStyle.ClassBreaks.Add(new ClassBreak(10, new Collection<Style> { windStyle1 }));  
             windClassBreakStyle.ClassBreaks.Add(new ClassBreak(20, new Collection<Style> { windStyle2 }));  
             windClassBreakStyle.ClassBreaks.Add(new ClassBreak(30, new Collection<Style> { windStyle3 }));  
             windClassBreakStyle.ClassBreaks.Add(new ClassBreak(40, new Collection<Style> { windStyle4 }));  
 
             InMemoryFeatureLayer windFeatureLayer = new InMemoryFeatureLayer();  
             windFeatureLayer.Open();  
             windFeatureLayer.Columns.Add(new FeatureSourceColumn("TEXT"));  
             windFeatureLayer.Columns.Add(new FeatureSourceColumn("ANGLE"));  
             windFeatureLayer.Columns.Add(new FeatureSourceColumn("LEVEL"));  
             windFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(windClassBreakStyle);  
             windFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             for (int i = 0; i < 20; i++)  
             {  
                 Feature windFeature = new Feature(random.Next(-13886070, -8906057), random.Next(3382985, 6660597));  
                 windFeature.ColumnValues["TEXT"] = random.Next(10, 40).ToString(CultureInfo.InvariantCulture);  
                 windFeature.ColumnValues["ANGLE"] = random.Next(0, 360).ToString(CultureInfo.InvariantCulture);  
                 windFeature.ColumnValues["LEVEL"] = random.Next(0, 5).ToString(CultureInfo.InvariantCulture);  
                 windFeatureLayer.InternalFeatures.Add(windFeature);  
             }  
 
             LayerOverlay dynamicOverlay = new LayerOverlay();  
             dynamicOverlay.Layers.Add(inMemoryFeatureLayerColdFront);  
             dynamicOverlay.Layers.Add(inMemoryFeatureLayerWarmFront);  
             dynamicOverlay.Layers.Add(inMemoryFeatureLayerOccludedFront);  
             dynamicOverlay.Layers.Add(pressureFeatureLayer);  
             dynamicOverlay.Layers.Add(windFeatureLayer);  
             MapView.Overlays.Add(dynamicOverlay);  
         }  
 
         private static CustomGeoImageLineStyle GetCustomLineStyle(LineStyle lineStyle, int space, CustomGeoImageLineStyle.SymbolSide symbolSide, params string[] imagePaths)  
         {  
             return new CustomGeoImageLineStyle(lineStyle, imagePaths.Select(p => new GeoImage(p)), space, symbolSide);  
         }  
     }  
 }  
 

PressureValueStyle.cs

 using System;  
 using System.Collections.Generic;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class PressureValueStyle : ValueStyle  
     {  
         public PressureValueStyle()  
         {  
             SquareTextPointStyle highPressurePointStyle = new SquareTextPointStyle();  
             highPressurePointStyle.Text = "H";  
             highPressurePointStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 39, 39, 245));  
 
             SquareTextPointStyle lowPressurePointStyle = new SquareTextPointStyle();  
             lowPressurePointStyle.Text = "L";  
             lowPressurePointStyle.SymbolSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.Red);  
 
             ValueItems.Add(new ValueItem("L", lowPressurePointStyle));  
             ValueItems.Add(new ValueItem("H", highPressurePointStyle));  
         }  
 
         public class SquareTextPointStyle : PointStyle  
         {  
             private string text;  
             private GeoFont font;  
             private GeoBrush textBrush;  
 
             public SquareTextPointStyle()  
             {  
                 SymbolType = PointSymbolType.Square;  
                 SymbolSize = 30;  
                 PointType = PointType.Symbol;  
                 font = new GeoFont("Verdana", 14);  
                 textBrush = new GeoSolidBrush(GeoColor.StandardColors.White);  
                 SymbolPen = new GeoPen(GeoColor.StandardColors.White, 1);  
             }  
 
             public string Text  
             {  
                 get { return text; }  
                 set { text = value; }  
             }  
 
             protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)  
             {  
                 base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers);  
 
                 double resolution = Math.Max(canvas.CurrentWorldExtent.Width / canvas.Width, canvas.CurrentWorldExtent.Height / canvas.Height);  
                 foreach (Feature feature in features)  
                 {  
                     PointShape pointShape = feature.GetShape() as PointShape;  
                     if (pointShape != null)  
                     {  
                         float screenOffsetX = (float)((pointShape.X - canvas.CurrentWorldExtent.UpperLeftPoint.X) / resolution);  
                         float screenOffsetY = (float)((canvas.CurrentWorldExtent.UpperLeftPoint.Y - pointShape.Y) / resolution);  
                         canvas.DrawTextWithScreenCoordinate(Text, font, textBrush, screenOffsetX, screenOffsetY, ThinkGeo.MapSuite.Core.DrawingLevel.LabelLevel);  
                     }  
                 }  
             }  
         }  
     }  
 }  
 

WindPointStyle.cs

 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class WindPointStyle : Style  
     {  
         private string textColumn;  
         private string angleColumn;  
         private string windLevelColumn;  
         private GeoFont font;  
         private GeoBrush textBrush;  
         private GeoSolidBrush fillBrush;  
         private GeoSolidBrush blackBrush;  
         private float directionLineLength1;  
         private float directionLineLength2;  
         private GeoPen outlinePen;  
         private GeoPen innerlinePen;  
 
         public WindPointStyle()  
             : this(string.Empty, string.Empty, string.Empty, GeoColor.StandardColors.Orange)  
         { }  
 
         public WindPointStyle(string textColumn, string levelColumn, string angleColumn, GeoColor fillColor)  
         {  
             this.directionLineLength1 = 40;  
             this.directionLineLength2 = 10;  
             this.blackBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black);  
             this.font = new GeoFont("Verdana", 14);  
             this.textBrush = new GeoSolidBrush(GeoColor.StandardColors.Black);  
             this.fillBrush = new GeoSolidBrush(fillColor);  
             this.outlinePen = new GeoPen(GeoColor.StandardColors.Black, 4);  
             this.innerlinePen = new GeoPen(fillBrush, 2);  
             this.textColumn = textColumn;  
             this.windLevelColumn = levelColumn;  
             this.angleColumn = angleColumn;  
         }  
 
         protected override Collection<string> GetRequiredColumnNamesCore()  
         {  
             return new Collection<string> { textColumn, angleColumn, windLevelColumn };  
         }  
 
         protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             double resolution = Math.Max(canvas.CurrentWorldExtent.Width / canvas.Width, canvas.CurrentWorldExtent.Height / canvas.Height);  
             foreach (var feature in features)  
             {  
                 PointShape pointShape = feature.GetShape() as PointShape;  
                 if (pointShape != null)  
                 {  
                     float screenOffsetX = (float)((pointShape.X - canvas.CurrentWorldExtent.UpperLeftPoint.X) / resolution);  
                     float screenOffsetY = (float)((canvas.CurrentWorldExtent.UpperLeftPoint.Y - pointShape.Y) / resolution);  
                     string angle = feature.ColumnValues[angleColumn];  
                     string level = feature.ColumnValues[windLevelColumn];  
                     int windLevel = int.Parse(level);  
 
                     ScreenPointF[] directionLine = null;  
                     ScreenPointF[] levelLine1 = null;  
                     ScreenPointF[] levelLine2 = null;  
 
                     if (!string.IsNullOrEmpty(angle))  
                     {  
                         double radian1 = double.Parse(angle) * Math.PI / 180;  
                         float x1 = (float)(directionLineLength1 * Math.Cos(radian1));  
                         float y1 = (float)(directionLineLength1 * Math.Sin(radian1));  
 
                         double radian2 = (double.Parse(angle) - 90) * Math.PI / 180;  
                         float x2 = (float)(directionLineLength2 * Math.Cos(radian2));  
                         float y2 = (float)(directionLineLength2 * Math.Sin(radian2));  
 
                         float x3 = (float)((directionLineLength1 - 8) * Math.Cos(radian1));  
                         float y3 = (float)((directionLineLength1 - 8) * Math.Sin(radian1));  
 
                         float x4 = (float)(directionLineLength2 * Math.Cos(radian2));  
                         float y4 = (float)(directionLineLength2 * Math.Sin(radian2));  
 
                         if (windLevel >= 1)  
                         {  
                             directionLine = new ScreenPointF[2];  
                             directionLine[0] = new ScreenPointF(screenOffsetX, screenOffsetY);  
                             directionLine[1] = new ScreenPointF(screenOffsetX + x1, screenOffsetY + y1);  
                         }  
 
                         if (windLevel >= 2)  
                         {  
                             levelLine1 = new ScreenPointF[2];  
                             levelLine1[0] = new ScreenPointF(screenOffsetX + x1, screenOffsetY + y1);  
                             levelLine1[1] = new ScreenPointF(screenOffsetX + x1 + x2, screenOffsetY + y1 + y2);  
                         }  
 
                         if (windLevel >= 3)  
                         {  
                             levelLine2 = new ScreenPointF[2];  
                             levelLine2[0] = new ScreenPointF(screenOffsetX + x3, screenOffsetY + y3);  
                             levelLine2[1] = new ScreenPointF(screenOffsetX + x3 + x4, screenOffsetY + y3 + y4);  
                         }  
                     }  
 
                     // draw back  
                     canvas.DrawEllipse(feature, 26, 26, blackBrush, DrawingLevel.LevelOne);  
                     if (directionLine != null) canvas.DrawLine(directionLine, outlinePen, DrawingLevel.LevelOne, 0, 0);  
                     if (levelLine1 != null) canvas.DrawLine(levelLine1, outlinePen, DrawingLevel.LevelOne, 0, 0);  
                     if (levelLine2 != null) canvas.DrawLine(levelLine2, outlinePen, DrawingLevel.LevelOne, 0, 0);  
 
                     //draw fore  
                     canvas.DrawEllipse(feature, 24, 24, fillBrush, DrawingLevel.LevelTwo);  
                     if (directionLine != null) canvas.DrawLine(directionLine, innerlinePen, DrawingLevel.LevelTwo, 0, 0);  
                     if (levelLine1 != null) canvas.DrawLine(levelLine1, innerlinePen, DrawingLevel.LevelTwo, 0, 0);  
                     if (levelLine2 != null) canvas.DrawLine(levelLine2, innerlinePen, DrawingLevel.LevelTwo, 0, 0);  
 
                     string text = feature.ColumnValues[textColumn];  
                     if (!string.IsNullOrEmpty(text))  
                     {  
                         canvas.DrawTextWithScreenCoordinate(text, font, textBrush, screenOffsetX, screenOffsetY, DrawingLevel.LabelLevel);  
                     }  
                 }  
             }  
         }  
     }  
 }  
 

FilterConditionDefaultValues.cs

 using System;  
 using System.Collections.Generic;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class FilterConditionDefaultValues : Dictionary<SimpleFilterConditionType, Tuple<string, string>>  
     {  
         public FilterConditionDefaultValues()  
         {  
             Add(SimpleFilterConditionType.Equal, "STATE_NAME", "Texas");  
             Add(SimpleFilterConditionType.Contains, "STATE_NAME", "T");  
             Add(SimpleFilterConditionType.StartsWith, "STATE_NAME", "T");  
             Add(SimpleFilterConditionType.EndsWith, "STATE_NAME", "a");  
             Add(SimpleFilterConditionType.DoesNotEqual, "STATE_NAME", "Texas");  
             Add(SimpleFilterConditionType.DoesNotContain, "STATE_NAME", "Te");  
             Add(SimpleFilterConditionType.GreaterThan, "POP1990", "1100000");  
             Add(SimpleFilterConditionType.GreaterThanOrEqualTo, "POP1990", "1003464");  
             Add(SimpleFilterConditionType.LessThan, "POP1990", "1003464");  
             Add(SimpleFilterConditionType.LessThanOrEqualTo, "POP1990", "1003464");  
             Add(SimpleFilterConditionType.IsEmpty, "STATE_NAME", string.Empty);  
             Add(SimpleFilterConditionType.IsNotEmpty, "STATE_NAME", string.Empty);  
         }  
 
         public void Add(SimpleFilterConditionType conditionType, string columnName, string matchValue)  
         {  
             Add(conditionType, new Tuple<string, string>(columnName, matchValue));  
         }  
     }  
 }  
 

FilterStyleSample.cs

 using Android.App;  
 using Android.Content;  
 using Android.Views;  
 using Android.Views.Animations;  
 using Android.Widget;  
 using System;  
 using System.Linq;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class FilterStyleSample : BaseSample  
     {  
         private TextView nameTextView;  
         private TextView valueEditText;  
         private FilterStyle filterStyle;  
         private Spinner conditionSpinner;  
         private LinearLayout settingsLinearLayout;  
         private FilterConditionDefaultValues filterConditionDefaultValues;  
 
         public FilterStyleSample(Context context)  
             : base(context)  
         { }  
 
 
         protected override void UpdateSampleLayoutCore()  
         {  
             FrameLayout mapContainerView = SampleView.FindViewById<FrameLayout>(Resource.Id.MapContainerView);  
 
             FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);  
             layoutParams.Gravity = GravityFlags.Bottom;  
 
             settingsLinearLayout = (LinearLayout)View.Inflate(Application.Context, Resource.Layout.FilterStyleSettings, null);  
             mapContainerView.AddView(settingsLinearLayout, layoutParams);  
 
             InitializeSettingView();  
 
             ImageButton settingsButton = SampleView.FindViewById<ImageButton>(Resource.Id.SettingsButton);  
             settingsButton.Click += SettingsButtonClick;  
             settingsButton.SetImageResource(Resource.Drawable.settings40);  
             settingsButton.SetBackgroundResource(Resource.Layout.ButtonBackgroundSelector);  
         }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.DecimalDegree;  
             MapView.CurrentExtent = new RectangleShape(-128.455625, 88.474096875, -65.174375, -9.084496875);  
 
             ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("states.shp"));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(statesLayer);  
             MapView.Overlays.Add("LayerOverlay", layerOverlay);  
 
             filterStyle = new FilterStyle();  
             SimpleFilterCondition newCondition = new SimpleFilterCondition("STATE_NAME", SimpleFilterConditionType.Equal, "Texas");  
             filterStyle.Conditions.Add(newCondition);  
 
             GeoColor fillColor = GeoColor.FromArgb(130, GeoColor.FromHtml("#ffb74c"));  
             GeoColor outlineColor = GeoColor.FromHtml("#333333");  
             filterStyle.Styles.Add(AreaStyles.CreateSimpleAreaStyle(fillColor, outlineColor));  
             statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(filterStyle);  
             statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
 
         private void SettingsButtonClick(object sender, EventArgs e)  
         {  
             if (settingsLinearLayout.Visibility == ViewStates.Visible)  
             {  
                 Animation animation = AnimationUtils.LoadAnimation(Application.Context, Resource.Animation.bottomViewOut);  
                 settingsLinearLayout.StartAnimation(animation);  
                 settingsLinearLayout.Visibility = ViewStates.Invisible;  
             }  
             else  
             {  
                 settingsLinearLayout.Visibility = ViewStates.Visible;  
                 Animation animation = AnimationUtils.LoadAnimation(Application.Context, Resource.Animation.bottomViewIn);  
                 settingsLinearLayout.StartAnimation(animation);  
             }  
         }  
 
         private void ApplyButtonClick(object sender, EventArgs e)  
         {  
             filterStyle.Conditions.Clear();  
             SimpleFilterCondition newCondition = new SimpleFilterCondition(nameTextView.Text, (SimpleFilterConditionType)conditionSpinner.SelectedItemId, valueEditText.Text);  
             filterStyle.Conditions.Add(newCondition);  
             MapView.Overlays["LayerOverlay"].Refresh();  
         }  
 
         private void InitializeSettingView()  
         {  
             Button applyButton = settingsLinearLayout.FindViewById<Button>(Resource.Id.applyButton);  
             ImageButton moreButton = settingsLinearLayout.FindViewById<ImageButton>(Resource.Id.moreImageButton);  
             LinearLayout headerLinearLayout = settingsLinearLayout.FindViewById<LinearLayout>(Resource.Id.headerLinearLayout);  
             conditionSpinner = settingsLinearLayout.FindViewById<Spinner>(Resource.Id.conditionSpinner);  
             ArrayAdapter<String> adapter = new ArrayAdapter<String>(Application.Context, Resource.Layout.SampleSpinnerCheckedText, Enum.GetNames(typeof(SimpleFilterConditionType)));  
             filterConditionDefaultValues = new FilterConditionDefaultValues();  
 
             applyButton.Click += ApplyButtonClick;  
             moreButton.Click += SettingsButtonClick;  
             headerLinearLayout.Click += SettingsButtonClick;  
 
             conditionSpinner.Adapter = adapter;  
             nameTextView = settingsLinearLayout.FindViewById<TextView>(Resource.Id.nameTextView);  
             nameTextView.Text = filterConditionDefaultValues.FirstOrDefault().Value.Item1;  
             valueEditText = settingsLinearLayout.FindViewById<TextView>(Resource.Id.valueEditText);  
             valueEditText.Text = filterConditionDefaultValues.FirstOrDefault().Value.Item2;  
 
             conditionSpinner.SetSelection(0);  
             conditionSpinner.ItemSelected += SpinnerItemSelected;  
         }  
 
         private void SpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)  
         {  
             string condition = conditionSpinner.GetItemAtPosition(e.Position).ToString();  
             SimpleFilterConditionType conditionType = (SimpleFilterConditionType)Enum.Parse(typeof(SimpleFilterConditionType), condition);  
             nameTextView.Text = filterConditionDefaultValues.SingleOrDefault(t => t.Key.Equals(conditionType)).Value.Item1;  
             valueEditText.Text = filterConditionDefaultValues.SingleOrDefault(t => t.Key.Equals(conditionType)).Value.Item2;  
             valueEditText.Visibility = condition.Contains("Empty") ? ViewStates.Invisible : ViewStates.Visible;  
         }  
     }  
 }  
 

EarthquakeIsoLineFeatureLayer.cs

 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.Globalization;  
 using System.Linq;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class EarthquakeIsoLineFeatureLayer : FeatureLayer  
     {  
         private DynamicIsoLineLayer isoLineLayer;  
         private ClassBreakStyle levelClassBreakStyle;  
 
         public EarthquakeIsoLineFeatureLayer()  
             : this(null)  
         { }  
 
         public EarthquakeIsoLineFeatureLayer(ShapeFileFeatureSource featureSource)  
         {  
             FeatureSource = featureSource;  
         }  
 
         public new FeatureSource FeatureSource  
         {  
             get { return base.FeatureSource; }  
             set  
             {  
                 base.FeatureSource = value;  
                 Initialize();  
             }  
         }  
 
         public Collection<double> IsoLineLevels  
         {  
             get { return isoLineLayer.IsoLineLevels; }  
         }  
 
         protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             isoLineLayer.Draw(canvas, labelsInAllLayers);  
         }  
 
         private void Initialize()  
         {  
             Collection<GeoColor> levelAreaColors = new Collection<GeoColor>();  
             levelAreaColors.Add(GeoColor.FromHtml("#FFFFBE"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDFF9E"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDFF37"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDDA04"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FFA701"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FF6F02"));  
             levelAreaColors.Add(GeoColor.FromHtml("#EC0000"));  
             levelAreaColors.Add(GeoColor.FromHtml("#B90000"));  
             levelAreaColors.Add(GeoColor.FromHtml("#850100"));  
             levelAreaColors.Add(GeoColor.FromHtml("#620001"));  
             levelAreaColors.Add(GeoColor.FromHtml("#450005"));  
             levelAreaColors.Add(GeoColor.FromHtml("#2B0804"));  
 
             FeatureSource.Open();  
 
             Dictionary<PointShape, double> dataPoints = GetDataPoints();  
             GridInterpolationModel interpolationModel = new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue);  
             isoLineLayer = new DynamicIsoLineLayer(dataPoints, GetClassBreakValues(dataPoints.Values, 12), interpolationModel, IsoLineType.ClosedLinesAsPolygons);  
 
             isoLineLayer.CellWidthInPixel = 32;  
             isoLineLayer.CellHeightInPixel = 32;  
             levelClassBreakStyle = new ClassBreakStyle(isoLineLayer.DataValueColumnName);  
             levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[0])))));  
             for (int i = 0; i < IsoLineLevels.Count - 1; i++)  
             {  
                 if (!levelClassBreakStyle.ClassBreaks.Any(c => c.Value == IsoLineLevels[i|+ 1]))  
                 {  
                     levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(IsoLineLevels[i|+ 1], new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[i|+ 1])))));  
                 }  
             }  
             isoLineLayer.CustomStyles.Add(levelClassBreakStyle);  
 
             TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);  
             textStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);  
             textStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;  
             textStyle.SplineType = SplineType.StandardSplining;  
             textStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels;  
             textStyle.TextLineSegmentRatio = 9999999;  
             textStyle.FittingLineInScreen = true;  
             textStyle.SuppressPartialLabels = true;  
             textStyle.NumericFormat = "{0:0.00}";  
             isoLineLayer.CustomStyles.Add(textStyle);  
         }  
 
         private Dictionary<PointShape, double> GetDataPoints()  
         {  
             return (from feature in FeatureSource.GetAllFeatures(GetReturningColumns())  
                     where double.Parse(feature.ColumnValues["MAGNITUDE"]) > 0  
                     select new PointShape  
                     {  
                         X = double.Parse(feature.ColumnValues["LONGITUDE"], CultureInfo.InvariantCulture),  
                         Y = double.Parse(feature.ColumnValues["LATITIUDE"], CultureInfo.InvariantCulture),  
                         Z = double.Parse(feature.ColumnValues["MAGNITUDE"], CultureInfo.InvariantCulture)  
                     }).ToDictionary(point => point, point => point.Z);  
         }  
 
         private static IEnumerable<double> GetClassBreakValues(IEnumerable<double> values, int count)  
         {  
             Collection<double> result = new Collection<double>();  
             double[] sortedValues = values.OrderBy(v => v).ToArray();  
             int classCount = sortedValues.Length / count;  
             for (int i = 1; i < count; i++)  
             {  
                 result.Add(sortedValues[i|* classCount]);  
             }  
 
             return result;  
         }  
 
         private static IEnumerable<string> GetReturningColumns()  
         {  
             //LONGITUDE  
             yield return "LONGITUDE";  
             //LATITIUDE  
             yield return "LATITIUDE";  
             //MAGNITUDE  
             yield return "MAGNITUDE";  
         }  
     }  
 }  
 

IsolineStyleSample.cs

 using Android.Content;  
 using ThinkGeo.MapSuite.AndroidEdition;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace AnalyzingVisualization  
 {  
     public class IsolineStyleSample : BaseSample  
     {  
         public IsolineStyleSample(Context context)  
             : base(context)  
         { }  
 
         protected override void InitializeMap()  
         {  
             MapView.MapUnit = GeographyUnit.Meter;  
             MapView.CurrentExtent = new RectangleShape(-15116491.8671313, 8720801.79162702, -11021545.2583953, 2603975.29482756);  
 
             WorldMapKitOverlay worldOverlay = (WorldMapKitOverlay)MapView.Overlays["WMK"];  
             worldOverlay.Projection = WorldMapKitProjection.SphericalMercator;  
             string baseFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;  
             string cachePathFilename = System.IO.Path.Combine(baseFolder, "MapSuiteTileCaches/SampleCaches.db");  
             worldOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "SphericalMercator");  
 
             EarthquakeIsoLineFeatureLayer usEarthquakeIsoLayer = new EarthquakeIsoLineFeatureLayer(new ShapeFileFeatureSource(SampleHelper.GetDataPath("usEarthquake_Simplified.shp")));  
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.TileSizeMode = TileSizeMode.DefaultX2;  
             layerOverlay.Layers.Add(usEarthquakeIsoLayer);  
             MapView.Overlays.Add(layerOverlay);  
         }  
     }  
 }  
 

ActivityListItemAdapter.cs

 using Android.App;  
 using Android.Graphics;  
 using Android.Views;  
 using Android.Widget;  
 using System;  
 using System.Collections.Generic;  
 
 namespace AnalyzingVisualization  
 {  
     public class ActivityListItemAdapter : ArrayAdapter<BaseSample>  
     {  
         private Activity context;  
         private float ratio;  
 
         public ActivityListItemAdapter(Activity context, IList<BaseSample> objects)  
             : base(context, Android.Resource.Id.Text1, objects)  
         {  
             this.context = context;  
         }  
 
         public override View GetView(int position, View convertView, ViewGroup parent)  
         {  
             ratio = context.Resources.DisplayMetrics.Density;  
 
             LinearLayout layout = (LinearLayout)context.LayoutInflater.Inflate(Android.Resource.Layout.ActivityListItem, null);  
             var item = GetItem(position);  
 
             TextView textView = layout.FindViewById<TextView>(Android.Resource.Id.Text1);  
             textView.Text = item.Title;  
             textView.SetTextColor(Color.Black);  
             textView.SetTextSize(Android.Util.ComplexUnitType.Px, 14 * ratio);  
             ((LinearLayout.LayoutParams)(textView.LayoutParameters)).Gravity = GravityFlags.CenterVertical;  
 
             ImageView imageView = layout.FindViewById<ImageView>(Android.Resource.Id.Icon);  
             imageView.SetImageResource(item.ImageId);  
             imageView.LayoutParameters.Width = (int)(30 * ratio);  
             imageView.LayoutParameters.Height = (int)(30 * ratio);  
             ((LinearLayout.LayoutParams)imageView.LayoutParameters).SetMargins(0, 2, 0, 2);  
 
             return layout;  
         }  
     }  
 }  
 

SampleHelper.cs

 using System.IO;  
 
 namespace AnalyzingVisualization  
 {  
     internal class SampleHelper  
     {  
         public static readonly string AssetsDataDictionary = @"AppData";  
         public static readonly string SampleDataDictionary = @"mnt/sdcard/MapSuiteSampleData/AnalyzingVisualization";  
 
         public static string GetDataPath(string fileName)  
         {  
             return Path.Combine(SampleDataDictionary, AssetsDataDictionary, fileName);  
         }  
     }  
 }  
 

SliderView.cs

 using Android.Content;  
 using Android.Util;  
 using Android.Views;  
 using Android.Widget;  
 using System;  
 
 namespace AnalyzingVisualization  
 {  
     public class SliderView : ViewGroup  
     {  
         private static readonly int VELOCITY_X_SPEED = 800;  
 
         private float x;  
         private Context context;  
         private Scroller scroller;  
         private bool dispatched;  
         private bool slided;  
         private int leftViewWidth;  
         private int startScrollLeftOffset;  
         private VelocityTracker mVelocityTracker;  
 
         public SliderView(Context context, IAttributeSet attrs)  
             : base(context, attrs)  
         {  
             this.context = context;  
             this.leftViewWidth = 200;  
             this.scroller = new Scroller(context);  
         }  
 
         public int LeftViewWidth  
         {  
             get { return leftViewWidth; }  
             set { leftViewWidth = value; }  
         }  
 
         public View LeftView  
         {  
             get { return this.GetChildAt(0); }  
         }  
 
         public ViewGroup MainView  
         {  
             get { return this.GetChildAt(1) as ViewGroup; }  
         }  
 
         protected override void OnLayout(bool arg0, int arg1, int arg2, int arg3, int arg4)  
         {  
             int childCount = this.ChildCount;  
             for (int i = 0; i < childCount; ++i)  
             {  
                 View view = this.GetChildAt(i);  
                 if (view.Visibility != ViewStates.Gone)  
                 {  
                     view.Layout(0, 0, view.MeasuredWidth, view.MeasuredHeight);  
                 }  
             }  
         }  
 
         public override bool OnInterceptTouchEvent(MotionEvent ev)  
         {  
             return true;  
         }  
 
         public override bool OnTouchEvent(MotionEvent e)  
         {  
             if (mVelocityTracker == null)  
             {  
                 mVelocityTracker = VelocityTracker.Obtain();  
             }  
             mVelocityTracker.AddMovement(e);  
             MotionEventActions action = e.Action;  
             if (action == MotionEventActions.Down)  
             {  
                 x = e.GetX();  
 
                 if (IsSlided())  
                 {  
                     dispatched = DispatchTouchEventToView(GetChildAt(0), e);  
                 }  
                 else  
                 {  
                     dispatched = DispatchTouchEventToView(GetChildAt(1), e);  
                 }  
             }  
             else if (action == MotionEventActions.Move)  
             {  
                 if (dispatched)  
                 {  
                     if (IsSlided())  
                     {  
                         DispatchTouchEventToView(GetChildAt(0), e);  
                     }  
                     else  
                     {  
                         DispatchTouchEventToView(GetChildAt(1), e);  
                     }  
                 }  
                 else  
                 {  
                     float dx = e.GetX() - x;  
                     View view = this.GetChildAt(1);  
                     int left = (int)(view.Left + dx);  
                     if (left >= 0)  
                     {  
                         view.Layout(left, view.Top, view.Width + left,  
                                 view.Top + view.Height);  
                     }  
                 }  
                 x = e.GetX();  
             }  
             else if (action == MotionEventActions.Cancel  
                   || action == MotionEventActions.Up)  
             {  
                 if (dispatched)  
                 {  
                     if (IsSlided())  
                     {  
                         DispatchTouchEventToView(GetChildAt(0), e);  
                     }  
                     else  
                     {  
                         DispatchTouchEventToView(GetChildAt(1), e);  
                     }  
                 }  
                 else  
                 {  
                     mVelocityTracker.ComputeCurrentVelocity(1000);  
                     int velocityX = (int)mVelocityTracker.GetXVelocity(0);  
                     if (velocityX > VELOCITY_X_SPEED)  
                     {  
                         SetSlided(true);  
                     }  
                     else if (velocityX < -VELOCITY_X_SPEED)  
                     {  
                         SetSlided(false);  
                     }  
                     else  
                     {  
                         View view = GetChildAt(1);  
                         if (view.Left >= view.Width / 2)  
                         {  
                             SetSlided(true);  
                         }  
                         else  
                         {  
                             SetSlided(false);  
                         }  
                     }  
                     if (mVelocityTracker != null)  
                     {  
                         try  
                         {  
                             mVelocityTracker.Recycle();  
                         }  
                         catch  
                         { }  
                     }  
                 }  
             }  
             else if (!IsSlided())  
             {  
                 DispatchTouchEventToView(GetChildAt(1), e);  
             }  
             return true;  
         }  
 
         public bool IsSlided()  
         {  
             return slided;  
         }  
 
         public void SetSlided(bool slided)  
         {  
             View view = GetChildAt(1);  
             startScrollLeftOffset = view.Left;  
             if (slided)  
             {  
                 scroller.StartScroll(0, Top, (int)(leftViewWidth * context.Resources.DisplayMetrics.Density) - startScrollLeftOffset, 0);  
             }  
             else  
             {  
                 scroller.StartScroll(0, Top, -startScrollLeftOffset, 0);  
             }  
             this.slided = slided;  
             PostInvalidate();  
         }  
 
         public override void ComputeScroll()  
         {  
             if (scroller.ComputeScrollOffset())  
             {  
                 View view = GetChildAt(1);  
                 int left = startScrollLeftOffset + scroller.CurrX;  
                 view.Layout(left, view.Top, left + view.Width, view.Height);  
                 PostInvalidate();  
             }  
         }  
 
         protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)  
         {  
             base.OnMeasure(widthMeasureSpec, heightMeasureSpec);  
             for (int i = 0; i < ChildCount; ++i)  
             {  
                 GetChildAt(i).Measure(widthMeasureSpec, heightMeasureSpec);  
             }  
         }  
 
         public bool DispatchTouchEventToView(View view, MotionEvent ev)  
         {  
             try  
             {  
                 return view.DispatchTouchEvent(ev);  
             }  
             catch (Exception e)  
             {  
                 // some machines will throw exception  
             }  
             return false;  
         }  
     }  
 }  
 
source_code_androideditionsample_visualization.zip.txt · Last modified: 2015/09/10 09:05 by admin