Table of Contents

Source Code iOS ProjectTemplates SiteSelection CS.zip

AppDelegate.cs

 using Foundation;  
 using UIKit;  
 
 namespace MapSuiteSiteSelection  
 {  
     // The UIApplicationDelegate for the application. This class is responsible for launching the  
     // User Interface of the application, as well as listening (and optionally responding) to  
     // application events from iOS.  
     [Register("AppDelegate")]  
     public partial class AppDelegate : UIApplicationDelegate  
     {  
         // class-level declarations  
         public override UIWindow Window  
         {  
             get;  
             set;  
         }  
         // This method is invoked when the application is about to move from active to inactive state.  
         // OpenGL applications should use this method to pause.  
         public override void OnResignActivation(UIApplication application)  
         {  
         }  
         // This method should be used to release shared resources and it should store the application state.  
         // If your application supports background exection this method is called instead of WillTerminate  
         // when the user quits.  
         public override void DidEnterBackground(UIApplication application)  
         {  
         }  
         // This method is called as part of the transiton from background to active state.  
         public override void WillEnterForeground(UIApplication application)  
         {  
         }  
         // This method is called when the application is about to terminate. Save data, if needed.  
         public override void WillTerminate(UIApplication application)  
         {  
         }  
     }  
 }  
 
 

Main.cs

 using UIKit;  
 
 namespace MapSuiteSiteSelection  
 {  
     public class Application  
     {  
         // This is the main entry point of the application.  
         static void Main(string[] args)  
         {  
             // if you want to use a different Application Delegate class from "AppDelegate"  
             // you can specify it here.  
             UIApplication.Main(args, null, "AppDelegate");  
         }  
     }  
 }  
 

MainViewController.cs

 using CoreGraphics;  
 using Foundation;  
 using UIKit;  
 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.Drawing;  
 using System.Globalization;  
 using System.IO;  
 using System.Linq;  
 using System.Net;  
 using System.Threading.Tasks;  
 using System.Xml;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.iOSEdition;  
 
 namespace MapSuiteSiteSelection  
 {  
     public partial class MainViewController : UIViewController  
     {  
         private MapView iOSMap;  
         private UIPopoverController optionsPopover;  
         private OptionsViewController optionsController;  
         private UINavigationController optionNavigationController;  
         private UITableViewController filterTypeTableViewController;  
         private UITableViewController pointSubTypeTableViewController;  
         private UITableViewController unitTypeTableViewController;  
         private BaseMapTypeController baseTypeTableViewController;  
 
         public MainViewController(IntPtr handle)  
             : base(handle)  
         {  
         }  
 
         public override void ViewDidLoad()  
         {  
             base.ViewDidLoad();  
 
             InitializeMap();  
             InitializeComponent();  
             InitializeSiteSelectionSetting();  
         }  
 
         public override void WillAnimateRotation(UIInterfaceOrientation toInterfaceOrientation, double duration)  
         {  
             base.WillAnimateRotation(toInterfaceOrientation, duration);  
 
             double resolution = Math.Max(iOSMap.CurrentExtent.Width / iOSMap.Frame.Width, iOSMap.CurrentExtent.Height / iOSMap.Frame.Height);  
             iOSMap.Frame = View.Frame;  
 
             iOSMap.CurrentExtent = GetExtentRetainScale(iOSMap.CurrentExtent.GetCenterPoint(), resolution);  
             iOSMap.Refresh();  
         }  
 
         private void InitializeMap()  
         {  
             string targetPoisDictionary = @"AppData/POIs";  
             string tempFolderRootPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CacheImages";  
 
             //LimitPolygon  
             ShapeFileFeatureLayer limitPolygonLayer = new ShapeFileFeatureLayer("AppData/SampleData/CityLimitPolygon.shp");  
             limitPolygonLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.White, 5.5f), new GeoSolidBrush(GeoColor.SimpleColors.Transparent)));  
             limitPolygonLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.Red, 1.5f) { DashStyle = LineDashStyle.Dash }, new GeoSolidBrush(GeoColor.SimpleColors.Transparent)));  
             limitPolygonLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             limitPolygonLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
             // WMK  
             WorldMapKitOverlay wmkOverlay = new WorldMapKitOverlay();  
             wmkOverlay.Projection = WorldMapKitProjection.SphericalMercator;  
 
             // OSM  
             OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();  
             osmOverlay.TileCache = new FileBitmapTileCache(tempFolderRootPath + "/OpenStreetMaps", "SphericalMercator");  
             osmOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;  
             osmOverlay.TileCache.TileMatrix.BoundingBox = osmOverlay.GetBoundingBox();  
             osmOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;  
             osmOverlay.IsVisible = false;  
 
             // Bing - Aerial  
             BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();  
             bingMapsAerialOverlay.MapStyle = BingMapsMapType.AerialWithLabels;  
             bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(tempFolderRootPath + "/BingMaps", "AerialWithLabels");  
             bingMapsAerialOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;  
             bingMapsAerialOverlay.TileCache.TileMatrix.BoundingBox = bingMapsAerialOverlay.GetBoundingBox();  
             bingMapsAerialOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;  
             bingMapsAerialOverlay.IsVisible = false;  
 
             // Bing - Road  
             BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();  
             bingMapsRoadOverlay.MapStyle = BingMapsMapType.Road;  
             bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(tempFolderRootPath + "/BingMaps", "Road");  
             bingMapsRoadOverlay.TileCache.TileMatrix.BoundingBoxUnit = GeographyUnit.Meter;  
             bingMapsRoadOverlay.TileCache.TileMatrix.BoundingBox = bingMapsRoadOverlay.GetBoundingBox();  
             bingMapsRoadOverlay.TileCache.ImageFormat = TileImageFormat.Jpeg;  
             bingMapsRoadOverlay.IsVisible = false;  
 
             ShapeFileFeatureLayer hotelsLayer = new ShapeFileFeatureLayer(Path.Combine(targetPoisDictionary, "Hotels.shp"));  
             hotelsLayer.Name = Global.HotelsLayerKey;  
             hotelsLayer.Transparency = 120f;  
             hotelsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImage("Hotel"));  
             hotelsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             hotelsLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
             ShapeFileFeatureLayer medicalFacilitesLayer = new ShapeFileFeatureLayer(Path.Combine(targetPoisDictionary, "Medical_Facilities.shp"));  
             medicalFacilitesLayer.Name = Global.MedicalFacilitiesLayerKey;  
             medicalFacilitesLayer.Transparency = 120f;  
             medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImage("DrugStore"));  
             medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             medicalFacilitesLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
 
             ShapeFileFeatureLayer publicFacilitesLayer = new ShapeFileFeatureLayer(Path.Combine(targetPoisDictionary, "Public_Facilities.shp"));  
             publicFacilitesLayer.Name = Global.PublicFacilitiesLayerKey;  
             publicFacilitesLayer.Transparency = 120f;  
             publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImage("public_facility"));  
             publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             publicFacilitesLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
             ShapeFileFeatureLayer restaurantsLayer = new ShapeFileFeatureLayer(Path.Combine(targetPoisDictionary, "Restaurants.shp"));  
             restaurantsLayer.Name = Global.RestaurantsLayerKey;  
             restaurantsLayer.Transparency = 120f;  
             restaurantsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImage("restaurant"));  
             restaurantsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             restaurantsLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
             ShapeFileFeatureLayer schoolsLayer = new ShapeFileFeatureLayer(Path.Combine(targetPoisDictionary, "Schools.shp"));  
             schoolsLayer.Name = Global.SchoolsLayerKey;  
             schoolsLayer.Transparency = 120f;  
             schoolsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImage("school"));  
             schoolsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             schoolsLayer.FeatureSource.Projection = Global.GetWgs84ToMercatorProjection();  
 
             //Highlight Overlay  
             GeoImage pinImage = GetGeoImage("pin");  
             InMemoryFeatureLayer highlightCenterMarkerLayer = new InMemoryFeatureLayer();  
             highlightCenterMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(pinImage);  
             highlightCenterMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.YOffsetInPixel = -(pinImage.GetHeight() / 2f);  
             highlightCenterMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             InMemoryFeatureLayer highlightMarkerLayer = new InMemoryFeatureLayer();  
             highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(GetGeoImage("selectedHalo"));  
             highlightMarkerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             InMemoryFeatureLayer highlightAreaLayer = new InMemoryFeatureLayer();  
             highlightAreaLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(new GeoColor(120, GeoColor.FromHtml("#1749c9")), GeoColor.FromHtml("#fefec1"), 3, LineDashStyle.Solid);  
             highlightAreaLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             LayerOverlay highlightOverlay = new LayerOverlay();  
             highlightOverlay.TileType = TileType.SingleTile;  
 
             highlightOverlay.Layers.Add(limitPolygonLayer);  
             highlightOverlay.Layers.Add(Global.HotelsLayerKey, hotelsLayer);  
             highlightOverlay.Layers.Add(Global.MedicalFacilitiesLayerKey, medicalFacilitesLayer);  
             highlightOverlay.Layers.Add(Global.PublicFacilitiesLayerKey, publicFacilitesLayer);  
             highlightOverlay.Layers.Add(Global.RestaurantsLayerKey, restaurantsLayer);  
             highlightOverlay.Layers.Add(Global.SchoolsLayerKey, schoolsLayer);  
             highlightOverlay.Layers.Add(Global.HighlightAreaLayerKey, highlightAreaLayer);  
             highlightOverlay.Layers.Add(Global.HighlightMarkerLayerKey, highlightMarkerLayer);  
             highlightOverlay.Layers.Add(Global.HighlightCenterMarkerLayerKey, highlightCenterMarkerLayer);  
 
             // Maps  
             iOSMap = new MapView(View.Frame);  
             iOSMap.MapUnit = GeographyUnit.Meter;  
             iOSMap.ZoomLevelSet = new BingMapsZoomLevelSet();  
             iOSMap.BackgroundColor = UIColor.FromRGB(244, 242, 238);  
             iOSMap.CurrentExtent = new RectangleShape(-10789390.0630888, 3924457.19413373, -10768237.5787263, 3906066.41190523);  
             iOSMap.TrackOverlay.TrackEnded += TrackInteractiveOverlayOnTrackEnded;  
 
             iOSMap.Overlays.Add(Global.OpenStreetMapOverlayKey, osmOverlay);  
             iOSMap.Overlays.Add(Global.WorldMapKitOverlayKey, wmkOverlay);  
             iOSMap.Overlays.Add(Global.BingMapsAerialOverlayKey, bingMapsAerialOverlay);  
             iOSMap.Overlays.Add(Global.BingMapsRoadOverlayKey, bingMapsRoadOverlay);  
             iOSMap.Overlays.Add(Global.HighLightOverlayKey, highlightOverlay);  
 
             Global.MapView = iOSMap;  
             Global.FilterConfiguration.QueryFeatureLayer = hotelsLayer;  
 
             View.Add(iOSMap);  
             iOSMap.Refresh();  
         }  
 
         private void InitializeComponent()  
         {  
             ToolbarCandidates toolBar = ToolbarCandidates.Instance;  
             toolBar.ToolBarButtonClick += ToolbarButtonClick;  
             operationToolbar.SetItems(toolBar.GetToolBarItems().ToArray(), true);  
             operationToolbar.TintColor = UIColor.FromRGB(103, 103, 103);  
 
             queryResultView.Hidden = true;  
             queryResultView.Layer.Opacity = 0.85f;  
             tbvQueryResult.Layer.Opacity = 0.85f;  
             tbvQueryResult.Layer.BorderWidth = 1;  
             tbvQueryResult.Layer.BorderColor = UIColor.Black.CGColor;  
             View.BringSubviewToFront(queryResultView);  
 
             alertViewShadow.Hidden = true;  
             View.BringSubviewToFront(alertViewShadow);  
 
             bingMapKeyAlertView.Hidden = true;  
             bingMapKeyAlertView.Center = View.Center;  
             View.BringSubviewToFront(bingMapKeyAlertView);  
 
             View.BringSubviewToFront(operationToolbar);  
 
             txtBingMapKey.ShouldReturn += textField =>  
             {  
                 textField.ResignFirstResponder();  
                 return true;  
             };  
         }  
 
         private void InitializeSiteSelectionSetting()  
         {  
             optionsController = (OptionsViewController)Global.FindViewController("OptionsViewController");  
             optionsController.OptionRowClick = OptionRowClick;  
             optionsController.QueryEarthquakeResult = RefreshQueryResultData;  
             optionsController.PreferredContentSize = new SizeF(420, 280);  
             optionNavigationController = new UINavigationController(optionsController);  
             optionNavigationController.PreferredContentSize = new SizeF(420, 280);  
 
             filterTypeTableViewController = new UITableViewController();  
             UITableView pointTypeTableView = new UITableView(View.Frame);  
             DataTableSource pointTypeSource = new DataTableSource();  
             Collection<RowModel> rows = new Collection<RowModel>();  
 
             string[] PoiLayerNameItems = { "Hotels", "Medical Facilites", "Restaurants", "Schools", "Public Facilites" };  
             foreach (var nameItem in PoiLayerNameItems)  
             {  
                 RowModel row = new RowModel(nameItem);  
                 row.CellAccessory = UITableViewCellAccessory.DisclosureIndicator;  
                 rows.Add(row);  
             }  
 
             SectionModel section = new SectionModel(string.Empty, rows);  
 
             pointTypeSource.Sections.Add(section);  
             pointTypeSource.RowClick = PointTypeRowClick;  
             pointTypeTableView.Source = pointTypeSource;  
             filterTypeTableViewController.View = pointTypeTableView;  
 
             pointSubTypeTableViewController = new UITableViewController();  
             pointSubTypeTableViewController.View = new UITableView(View.Frame);  
 
             unitTypeTableViewController = new UITableViewController();  
             UITableView unitTypeTableView = new UITableView(View.Frame);  
             DataTableSource unitTypeSource = new DataTableSource();  
             Collection<RowModel> unitTypeRows = new Collection<RowModel>();  
 
             //Create Unit Type table view controller.  
             string[] unitTypeItems = { "Miles", "Kilometers" };  
             foreach (var nameItem in unitTypeItems)  
             {  
                 RowModel row = new RowModel(nameItem);  
                 row.CellAccessory = UITableViewCellAccessory.Checkmark;  
                 unitTypeRows.Add(row);  
             }  
 
             SectionModel unitTypeSection = new SectionModel(string.Empty, unitTypeRows);  
 
             unitTypeSource.Sections.Add(unitTypeSection);  
             unitTypeSource.RowClick = UnitTypeRowClick;  
             unitTypeTableView.Source = unitTypeSource;  
             unitTypeTableViewController.View = unitTypeTableView;  
 
             baseTypeTableViewController = new BaseMapTypeController();  
             baseTypeTableViewController.RowClick = (view, path) =>  
             {  
                 optionNavigationController.PopToRootViewController(true);  
                 DismissOptionController();  
             };  
             baseTypeTableViewController.DispalyBingMapKeyAlertView = ShowBingMapKeyAlertView;  
         }  
 
         private void DismissOptionController()  
         {  
             if (Global.UserInterfaceIdiomIsPhone)  
                 optionsController.DismissViewController(true, null);  
             else  
                 optionsPopover.Dismiss(true);  
         }  
 
         private void TrackInteractiveOverlayOnTrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs args)  
         {  
             Feature centerFeature = iOSMap.TrackOverlay.TrackShapeLayer.InternalFeatures.FirstOrDefault();  
 
             InMemoryFeatureLayer highlightCenterMarkerLayer = (InMemoryFeatureLayer)Global.HighLightOverlay.Layers[Global.HighlightCenterMarkerLayerKey];  
 
             highlightCenterMarkerLayer.InternalFeatures.Clear();  
             highlightCenterMarkerLayer.InternalFeatures.Add(centerFeature);  
 
             MapSuiteSampleHelper.UpdateHighlightOverlay();  
             RefreshQueryResultData();  
 
             iOSMap.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();  
         }  
 
         private void ToolbarButtonClick(object sender, EventArgs e)  
         {  
             UIBarButtonItem buttonItem = (UIBarButtonItem)sender;  
             queryResultView.AnimatedHide();  
             if (buttonItem != null)  
             {  
                 switch (buttonItem.Title)  
                 {  
                     case SiteSelectionConstant.Pan:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.None;  
                         break;  
 
                     case SiteSelectionConstant.Pin:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.Point;  
                         break;  
 
                     case SiteSelectionConstant.Clear:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.None;  
                         ClearQueryResult();  
                         break;  
 
                     case SiteSelectionConstant.Search:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.None;  
                         RefreshQueryResultData();  
                         break;  
 
                     case SiteSelectionConstant.Options:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.None;  
                         ShowOptionsPopover(optionNavigationController);  
                         break;  
 
                     default:  
                         iOSMap.TrackOverlay.TrackMode = TrackMode.None;  
                         break;  
                 }  
                 RefreshToolbarItem(operationToolbar, buttonItem);  
             }  
         }  
 
         private void ClearQueryResult()  
         {  
             LayerOverlay highlightOverlay = Global.HighLightOverlay;  
 
             InMemoryFeatureLayer highlightAreaLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightAreaLayerKey];  
             InMemoryFeatureLayer highlightMarkerLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightMarkerLayerKey];  
             InMemoryFeatureLayer highlightCenterMarkerLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightCenterMarkerLayerKey];  
 
             highlightAreaLayer.InternalFeatures.Clear();  
             highlightMarkerLayer.InternalFeatures.Clear();  
             highlightCenterMarkerLayer.InternalFeatures.Clear();  
 
             highlightOverlay.Refresh();  
 
             tbvQueryResult.Source = null;  
             tbvQueryResult.ReloadData();  
         }  
 
         private void ShowOptionsPopover(UIViewController popoverContentController)  
         {  
             if (Global.UserInterfaceIdiomIsPhone)  
             {  
                 popoverContentController.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext;  
                 popoverContentController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;  
                 PresentViewController(optionNavigationController, true, null);  
             }  
             else  
             {  
                 if (optionsPopover == null) optionsPopover = new UIPopoverController(popoverContentController);  
                 optionsPopover.PresentFromRect(new CGRect(View.Frame.Width - 25, View.Frame.Height - 40, 40, 40), View, UIPopoverArrowDirection.Down, true);  
             }  
         }  
 
         private void ShowBingMapKeyAlertView()  
         {  
             alertViewShadow.Hidden = false;  
             bingMapKeyAlertView.Hidden = false;  
             DismissOptionController();  
         }  
 
         private void OptionRowClick(string itemName)  
         {  
             if (itemName.Contains("/"))  
                 optionNavigationController.PushViewController(filterTypeTableViewController, true);  
             else if (itemName.Equals("UnitType"))  
                 optionNavigationController.PushViewController(unitTypeTableViewController, true);  
             else if (itemName.Equals("Base Map"))  
                 optionNavigationController.PushViewController(baseTypeTableViewController, true);  
             else  
                 DismissOptionController();  
         }  
 
         private void PointTypeRowClick(UITableView tableView, NSIndexPath indexPath)  
         {  
             DataTableSource source = (DataTableSource)tableView.Source;  
             string pointType = source.Sections[indexPath.Section].Rows[indexPath.Row].Name;  
 
             Global.FilterConfiguration.QueryFeatureLayer = GetQueryLayer(pointType);  
 
             UITableView pointSubTypeTableView = (UITableView)pointSubTypeTableViewController.View;  
             DataTableSource subTypeSource = new DataTableSource();  
             subTypeSource.RowClick = PointSubTypeRowClick;  
 
             string selectColumnName = GetDefaultColumnNameByPoiType(pointType);  
             Global.FilterConfiguration.QueryColumnName = selectColumnName;  
 
             IEnumerable<string> columns = GetColumnValueCandidates(selectColumnName);  
             Collection<RowModel> rows = new Collection<RowModel>();  
             foreach (var nameItem in columns)  
             {  
                 RowModel row = new RowModel(nameItem);  
                 row.CellAccessory = UITableViewCellAccessory.Checkmark;  
                 rows.Add(row);  
             }  
             subTypeSource.Sections.Add(new SectionModel(string.Empty, rows));  
             pointSubTypeTableView.Source = subTypeSource;  
 
             optionNavigationController.PushViewController(pointSubTypeTableViewController, true);  
         }  
 
         private void PointSubTypeRowClick(UITableView tableView, NSIndexPath indexPath)  
         {  
             DataTableSource source = (DataTableSource)tableView.Source;  
             string subPointType = source.Sections[indexPath.Section].Rows[indexPath.Row].Name;  
             Global.FilterConfiguration.QueryColumnValue = subPointType;  
 
             foreach (var row in source.Sections[0].Rows)  
             {  
                 row.IsChecked = row.Name.Equals(subPointType);  
             }  
             tableView.ReloadData();  
             RefreshQueryResultData();  
 
             optionNavigationController.PopToRootViewController(true);  
             DismissOptionController();  
             iOSMap.Refresh();  
         }  
 
         private void UnitTypeRowClick(UITableView tableView, NSIndexPath indexPath)  
         {  
             DataTableSource source = (DataTableSource)tableView.Source;  
             string unitType = source.Sections[indexPath.Section].Rows[indexPath.Row].Name;  
 
             DistanceUnit distanceUnit;  
             if (Enum.TryParse(unitType.TrimEnd('s'), true, out distanceUnit))  
                 Global.FilterConfiguration.BufferDistanceUnit = distanceUnit;  
 
             foreach (var row in source.Sections[0].Rows)  
             {  
                 row.IsChecked = row.Name.Equals(unitType);  
             }  
             tableView.ReloadData();  
             RefreshQueryResultData();  
 
             optionNavigationController.PopToRootViewController(true);  
             DismissOptionController();  
             iOSMap.Refresh();  
         }  
 
         private FeatureLayer GetQueryLayer(string pointType)  
         {  
             FeatureLayer resultLayer = null;  
             LayerOverlay poiOverlay = Global.HighLightOverlay;  
             switch (pointType)  
             {  
                 case "Hotels":  
                     resultLayer = (FeatureLayer)poiOverlay.Layers[Global.HotelsLayerKey];  
                     break;  
                 case "Medical Facilites":  
                     resultLayer = (FeatureLayer)poiOverlay.Layers[Global.MedicalFacilitiesLayerKey];  
                     break;  
                 case "Restaurants":  
                     resultLayer = (FeatureLayer)poiOverlay.Layers[Global.RestaurantsLayerKey];  
                     break;  
                 case "Schools":  
                     resultLayer = (FeatureLayer)poiOverlay.Layers[Global.SchoolsLayerKey];  
                     break;  
                 case "Public Facilites":  
                     resultLayer = (FeatureLayer)poiOverlay.Layers[Global.PublicFacilitiesLayerKey];  
                     break;  
             }  
             return resultLayer;  
         }  
 
         private IEnumerable<string> GetColumnValueCandidates(string selectColumnName)  
         {  
             Collection<string> candidates = new Collection<string>();  
             candidates.Add(Global.AllFeatureKey);  
             if (selectColumnName.Equals("ROOMS"))  
             {  
                 candidates.Add("1 ~ 50");  
                 candidates.Add("50 ~ 100");  
                 candidates.Add("100 ~ 150");  
                 candidates.Add("150 ~ 200");  
                 candidates.Add("200 ~ 300");  
                 candidates.Add("300 ~ 400");  
                 candidates.Add("400 ~ 500");  
                 candidates.Add(">= 500");  
             }  
             else  
             {  
                 Global.FilterConfiguration.QueryFeatureLayer.Open();  
                 IEnumerable<string> distinctColumnValues = Global.FilterConfiguration.QueryFeatureLayer.FeatureSource.GetDistinctColumnValues(selectColumnName).Select(v => v.ColumnValue);  
                 foreach (var distinctColumnValue in distinctColumnValues)  
                 {  
                     candidates.Add(distinctColumnValue);  
                 }  
             }  
             candidates.Remove(string.Empty);  
 
             return candidates;  
         }  
 
         private string GetDefaultColumnNameByPoiType(string poiType)  
         {  
             string result = string.Empty;  
             if (poiType.Equals("Restaurants", StringComparison.OrdinalIgnoreCase))  
             {  
                 result = "FoodType";  
             }  
             else if (poiType.Equals("Medical Facilites", StringComparison.OrdinalIgnoreCase)  
                 || poiType.Equals("Schools", StringComparison.OrdinalIgnoreCase))  
             {  
                 result = "TYPE";  
             }  
             else if (poiType.Equals("Public Facilites", StringComparison.OrdinalIgnoreCase))  
             {  
                 result = "AGENCY";  
             }  
             else if (poiType.Equals("Hotels", StringComparison.OrdinalIgnoreCase))  
             {  
                 result = "ROOMS";  
             }  
             return result;  
         }  
 
         private void RefreshToolbarItem(UIToolbar toolbar, UIBarButtonItem buttonItem)  
         {  
             UIColor defaultColor = UIColor.FromRGB(103, 103, 103);  
             UIColor highlightColor = UIColor.FromRGB(27, 119, 222);  
             // Set all item color to default.  
             foreach (var item in toolbar.Items)  
             {  
                 item.TintColor = defaultColor;  
             }  
 
             if (buttonItem.Title.Equals(SiteSelectionConstant.Pin))  
                 buttonItem.TintColor = highlightColor;  
         }  
 
         private void RefreshQueryResultData()  
         {  
             if (queryResultView.Hidden) queryResultView.AnimatedShow();  
             DataTableSource similarSiteSourceSource;  
             if (tbvQueryResult.Source == null)  
             {  
                 similarSiteSourceSource = new DataTableSource();  
                 similarSiteSourceSource.RowClick = SimilarSiteSourceRowClicked;  
                 tbvQueryResult.Source = similarSiteSourceSource;  
             }  
             else  
             {  
                 similarSiteSourceSource = (DataTableSource)tbvQueryResult.Source;  
             }  
             similarSiteSourceSource.Sections.Clear();  
 
             InMemoryFeatureLayer highlightMarkerLayer =  
                 (InMemoryFeatureLayer)Global.HighLightOverlay.Layers[Global.HighlightMarkerLayerKey];  
 
             MapSuiteSampleHelper.UpdateHighlightOverlay();  
 
             GeoCollection<Feature> selectionFeatures = highlightMarkerLayer.InternalFeatures;  
 
             SectionModel sectionModel = new SectionModel("Queried Count: " + selectionFeatures.Count);  
             sectionModel.HeaderHeight = 50;  
             foreach (var feature in highlightMarkerLayer.InternalFeatures)  
             {  
                 sectionModel.Rows.Add(new RowModel(feature.ColumnValues["Name"], new UIImageView(UIImage.FromBundle("location"))));  
             }  
             similarSiteSourceSource.Sections.Add(sectionModel);  
 
             tbvQueryResult.ReloadData();  
         }  
 
         private void SimilarSiteSourceRowClicked(UITableView tableView, NSIndexPath indexPath)  
         {  
             InMemoryFeatureLayer selectMarkerLayer = (InMemoryFeatureLayer)Global.HighLightOverlay.Layers[Global.HighlightMarkerLayerKey];  
             Feature queryFeature = selectMarkerLayer.InternalFeatures[indexPath.Row];  
 
             iOSMap.ZoomTo(queryFeature.GetBoundingBox().GetCenterPoint(), iOSMap.ZoomLevelSet.ZoomLevel15.Scale);  
         }  
 
         partial void btnCancel_TouchUpInside(UIButton sender)  
         {  
             alertViewShadow.Hidden = true;  
             bingMapKeyAlertView.Hidden = true;  
             txtBingMapKey.EndEditing(true);  
         }  
 
         partial void btnOk_TouchUpInside(UIButton sender)  
         {  
             btnOk.Enabled = false;  
             btnCancel.Enabled = false;  
             txtBingMapKey.EndEditing(true);  
 
             string bingMapKey = txtBingMapKey.Text;  
 
             Task.Factory.StartNew(() =>  
             {  
                 bool isValid = ValidateBingMapKey(bingMapKey, BingMapsMapType.Aerial);  
                 iOSMap.BeginInvokeOnMainThread(() =>  
                 {  
                     if (isValid)  
                     {  
                         Global.BingMapsAerialOverlay.ApplicationId = bingMapKey;  
                         Global.BingMapsRoadOverlay.ApplicationId = bingMapKey;  
 
                         Global.OpenStreetMapOverlay.IsVisible = false;  
                         Global.BingMapsAerialOverlay.IsVisible = Global.BaseMapType == BaseMapType.BingMapsAerial;  
                         Global.BingMapsRoadOverlay.IsVisible = Global.BaseMapType == BaseMapType.BingMapsRoad;  
 
                         alertViewShadow.Hidden = true;  
                         bingMapKeyAlertView.Hidden = true;  
                         iOSMap.Refresh();  
                     }  
                     else  
                     {  
                         lblBingMapKeyMessage.Text = "The input BingMapKey is not validate.";  
                     }  
                     btnOk.Enabled = true;  
                     btnCancel.Enabled = true;  
                 });  
             });  
         }  
 
         private GeoImage GetGeoImage(string name)  
         {  
             return new GeoImage(UIImage.FromBundle(name).AsPNG().AsStream());  
         }  
 
         private RectangleShape GetExtentRetainScale(PointShape currentLocationInMecator, double resolution = double.NaN)  
         {  
             if (double.IsNaN(resolution))  
             {  
                 resolution = Math.Max(iOSMap.CurrentExtent.Width / iOSMap.Frame.Width, iOSMap.CurrentExtent.Height / iOSMap.Frame.Height);  
             }  
 
             double left = currentLocationInMecator.X - resolution * iOSMap.Frame.Width * .5;  
             double right = currentLocationInMecator.X + resolution * iOSMap.Frame.Width * .5;  
             double top = currentLocationInMecator.Y + resolution * iOSMap.Frame.Height * .5;  
             double bottom = currentLocationInMecator.Y - resolution * iOSMap.Frame.Height * .5;  
             return new RectangleShape(left, top, right, bottom);  
         }  
 
         private bool ValidateBingMapKey(string bingMapsKey, BingMapsMapType mapType)  
         {  
             bool result = false;  
 
             Stream stream = null;  
 
             string loginServiceTemplate = "http://dev.virtualearth.net/REST/v1/Imagery/Metadata/{0}?&incl=ImageryProviders&o=xml&key={1}";  
 
             try  
             {  
                 string loginServiceUri = string.Format(CultureInfo.InvariantCulture, loginServiceTemplate, mapType, bingMapsKey);  
 
                 Uri uri = new Uri(loginServiceUri);  
                 WebRequest webRequest = new HttpWebRequest(uri);  
                 WebResponse response = webRequest.GetResponse();  
                 stream = response.GetResponseStream();  
 
                 if (stream != null)  
                 {  
                     XmlDocument xDoc = new XmlDocument();  
                     xDoc.Load(stream);  
                     XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDoc.NameTable);  
                     nsmgr.AddNamespace("bing", "http://schemas.microsoft.com/search/local/ws/rest/v1");  
 
                     XmlNode root = xDoc.SelectSingleNode("bing:Response", nsmgr);  
                     XmlNode imageUrlElement = root.SelectSingleNode("bing:ResourceSets/bing:ResourceSet/bing:Resources/bing:ImageryMetadata/bing:ImageUrl", nsmgr);  
                     XmlNodeList subdomainsElement = root.SelectNodes("bing:ResourceSets/bing:ResourceSet/bing:Resources/bing:ImageryMetadata/bing:ImageUrlSubdomains/bing:string", nsmgr);  
                     if (imageUrlElement != null && subdomainsElement != null)  
                     {  
                         result = true;  
                     }  
                 }  
             }  
             catch  
             { }  
             finally  
             {  
                 if (stream != null) stream.Dispose();  
             }  
 
             return result;  
         }  
     }  
 }  
 

MainViewController.designer.cs

 // WARNING  
 //  
 // This file has been generated automatically by Xamarin Studio from the outlets and  
 // actions declared in your storyboard file.  
 // Manual changes to this file will not be maintained.  
 //  
 using System;  
 using Foundation;  
 using UIKit;  
 using System.CodeDom.Compiler;  
 
 namespace MapSuiteSiteSelection  
 {  
 	[Register|("MainViewController")]  
 	partial class MainViewController  
 	{  
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIView alertViewShadow { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIView bingMapKeyAlertView { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIButton btnCancel { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIButton btnOk { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UILabel lblBingMapKeyMessage { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIToolbar operationToolbar { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIView queryResultView { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UITableView tbvQueryResult { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UITextField txtBingMapKey { get; set; }  
 
 		[Action|("btnCancel_TouchUpInside:")]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		partial void btnCancel_TouchUpInside (UIButton sender);  
 
 		[Action|("btnOk_TouchUpInside:")]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		partial void btnOk_TouchUpInside (UIButton sender);  
 
 		void ReleaseDesignerOutlets ()  
 		{  
 			if (alertViewShadow != null) {  
 				alertViewShadow.Dispose ();  
 				alertViewShadow = null;  
 			}  
 			if (bingMapKeyAlertView != null) {  
 				bingMapKeyAlertView.Dispose ();  
 				bingMapKeyAlertView = null;  
 			}  
 			if (btnCancel != null) {  
 				btnCancel.Dispose ();  
 				btnCancel = null;  
 			}  
 			if (btnOk != null) {  
 				btnOk.Dispose ();  
 				btnOk = null;  
 			}  
 			if (lblBingMapKeyMessage != null) {  
 				lblBingMapKeyMessage.Dispose ();  
 				lblBingMapKeyMessage = null;  
 			}  
 			if (operationToolbar != null) {  
 				operationToolbar.Dispose ();  
 				operationToolbar = null;  
 			}  
 			if (queryResultView != null) {  
 				queryResultView.Dispose ();  
 				queryResultView = null;  
 			}  
 			if (tbvQueryResult != null) {  
 				tbvQueryResult.Dispose ();  
 				tbvQueryResult = null;  
 			}  
 			if (txtBingMapKey != null) {  
 				txtBingMapKey.Dispose ();  
 				txtBingMapKey = null;  
 			}  
 		}  
 	}  
 }  
 
 

QueryResultView.designer.cs

 // WARNING  
 //  
 // This file has been generated automatically by Xamarin Studio from the outlets and  
 // actions declared in your storyboard file.  
 // Manual changes to this file will not be maintained.  
 //  
 using System;  
 using MonoTouch.Foundation;  
 using MonoTouch.UIKit;  
 using System.CodeDom.Compiler;  
 
 namespace MapSuiteEarthquakeStatistics  
 {  
 	[Register|("QueryResultView")]  
 	partial class QueryResultView  
 	{  
 		void ReleaseDesignerOutlets ()  
 		{  
 		}  
 	}  
 }  
 
 

BaseMapTypeController.cs

 using System;  
 using System.Collections.ObjectModel;  
 using Foundation;  
 using ThinkGeo.MapSuite.Core;  
 using UIKit;  
 
 namespace MapSuiteSiteSelection  
 {  
     [Register("BaseMapTypeController")]  
     public class BaseMapTypeController : UITableViewController  
     {  
         public Action DispalyBingMapKeyAlertView;  
         public Action<UITableView, NSIndexPath> RowClick;  
 
         public BaseMapTypeController()  
         {  
         }  
 
         public override void ViewDidLoad()  
         {  
             base.ViewDidLoad();  
 
             UITableView baseMapTypeTableView = new UITableView(View.Frame);  
             DataTableSource baseMapTypeSource = new DataTableSource();  
             Collection<RowModel> baseMapTypeRows = new Collection<RowModel>();  
 
             string[] baseMapTypeItems = { "World Map Kit Road", "World Map Kit Aerial", "World Map Kit Aerial With Labels", "Open Street Map", "Bing Maps Aerial", "Bing Maps Road" };  
             foreach (var nameItem in baseMapTypeItems)  
             {  
                 RowModel row = new RowModel(nameItem);  
                 row.CellAccessory = UITableViewCellAccessory.Checkmark;  
                 baseMapTypeRows.Add(row);  
             }  
             baseMapTypeRows[0].IsChecked = true;  
 
             SectionModel baseMapTypeSection = new SectionModel(string.Empty, baseMapTypeRows);  
 
             baseMapTypeSource.Sections.Add(baseMapTypeSection);  
             baseMapTypeSource.RowClick = BaseMapTypeRowClick;  
             baseMapTypeTableView.Source = baseMapTypeSource;  
             View = baseMapTypeTableView;  
         }  
 
         private void BaseMapTypeRowClick(UITableView tableView, NSIndexPath indexPath)  
         {  
             DataTableSource source = (DataTableSource)tableView.Source;  
             string selectedItem = source.Sections[indexPath.Section].Rows[indexPath.Row].Name;  
             Global.BaseMapTypeString = selectedItem;  
 
             foreach (var row in source.Sections[0].Rows)  
             {  
                 row.IsChecked = row.Name.Equals(selectedItem);  
             }  
 
             tableView.ReloadData();  
             RefreshBaseMap();  
             if (RowClick != null) RowClick(tableView, indexPath);  
         }  
 
         private void RefreshBaseMap()  
         {  
             BaseMapType mapType;  
             string baseMapTypeString = Global.BaseMapTypeString.Replace(" ", "");  
             if (Enum.TryParse(baseMapTypeString, true, out mapType)) Global.BaseMapType = mapType;  
 
             switch (Global.BaseMapType)  
             {  
                 case BaseMapType.WorldMapKitRoad:  
                     Global.WorldMapKitOverlay.MapType = WorldMapKitMapType.Road;  
                     Global.WorldMapKitOverlay.IsVisible = true;  
                     Global.OpenStreetMapOverlay.IsVisible = false;  
                     Global.BingMapsAerialOverlay.IsVisible = false;  
                     Global.BingMapsRoadOverlay.IsVisible = false;  
                     Global.MapView.Refresh();  
                     break;  
                 case BaseMapType.WorldMapKitAerial:  
                     Global.WorldMapKitOverlay.MapType = WorldMapKitMapType.Aerial;  
                     Global.WorldMapKitOverlay.IsVisible = true;  
                     Global.OpenStreetMapOverlay.IsVisible = false;  
                     Global.BingMapsAerialOverlay.IsVisible = false;  
                     Global.BingMapsRoadOverlay.IsVisible = false;  
                     Global.MapView.Refresh();  
                     break;  
                 case BaseMapType.WorldMapKitAerialWithLabels:  
                     Global.WorldMapKitOverlay.MapType = WorldMapKitMapType.AerialWithLabels;  
                     Global.WorldMapKitOverlay.IsVisible = true;  
                     Global.OpenStreetMapOverlay.IsVisible = false;  
                     Global.BingMapsAerialOverlay.IsVisible = false;  
                     Global.BingMapsRoadOverlay.IsVisible = false;  
                     Global.MapView.Refresh();  
                     break;  
                 case BaseMapType.OpenStreetMap:  
                     Global.WorldMapKitOverlay.IsVisible = false;  
                     Global.OpenStreetMapOverlay.IsVisible = true;  
                     Global.BingMapsAerialOverlay.IsVisible = false;  
                     Global.BingMapsRoadOverlay.IsVisible = false;  
                     Global.MapView.Refresh();  
                     break;  
                 case BaseMapType.BingMapsAerial:  
                 case BaseMapType.BingMapsRoad:  
                     string applicatoinId = Global.BingMapKey;  
                     if (!string.IsNullOrEmpty(applicatoinId))  
                     {  
                         Global.BingMapsAerialOverlay.ApplicationId = applicatoinId;  
                         Global.BingMapsRoadOverlay.ApplicationId = applicatoinId;  
 
                         Global.WorldMapKitOverlay.IsVisible = false;  
                         Global.OpenStreetMapOverlay.IsVisible = false;  
                         Global.BingMapsAerialOverlay.IsVisible = Global.BaseMapType == BaseMapType.BingMapsAerial;  
                         Global.BingMapsRoadOverlay.IsVisible = Global.BaseMapType == BaseMapType.BingMapsRoad;  
                         Global.MapView.Refresh();  
                     }  
                     else  
                     {  
                         if (DispalyBingMapKeyAlertView != null) DispalyBingMapKeyAlertView();  
                     }  
                     break;  
             }  
         }  
     }  
 }  
 

OptionsViewController.cs

 using Foundation;  
 using UIKit;  
 using System;  
 using System.Collections.ObjectModel;  
 using System.Drawing;  
 
 namespace MapSuiteSiteSelection  
 {  
     partial class OptionsViewController : UIViewController  
     {  
         private DataTableSource optionsSource;  
         private RowModel typeFilterModel;  
         private UIButton unitTypeButton;  
         private UILabel baseMapLabel;  
 
         public Action QueryEarthquakeResult;  
         public Action<string> OptionRowClick;  
 
         public OptionsViewController(IntPtr handle)  
             : base(handle)  
         {  
         }  
 
         public override void ViewDidLoad()  
         {  
             base.ViewDidLoad();  
             Title = "Site Selection Setting";  
             InitializeOptionsSource();  
         }  
 
         public override void ViewDidAppear(bool animated)  
         {  
             typeFilterModel.Name = Global.FilterConfiguration.QueryColumnName + "/" +  
                                    Global.FilterConfiguration.QueryColumnValue;  
             unitTypeButton.SetTitle(Global.FilterConfiguration.BufferDistanceUnit + "s", UIControlState.Normal);  
             baseMapLabel.Text = Global.BaseMapTypeString ?? "World Map Kit Road";  
             tbvOptions.ReloadData();  
         }  
 
         private void InitializeOptionsSource()  
         {  
             int rowWidth = 400;  
             if (Global.UserInterfaceIdiomIsPhone)  
             {  
                 rowWidth = 300;  
             }  
 
             optionsSource = new DataTableSource();  
             optionsSource.RowClick += RowClick;  
 
             Collection<RowModel> baseMapRows = new Collection<RowModel>();  
             RowModel baseMapModel = new RowModel("Base Map");  
             baseMapLabel = new UILabel(new RectangleF(5, 5, rowWidth * 0.6f, 40));  
             baseMapLabel.TextAlignment = UITextAlignment.Right;  
             baseMapLabel.TextColor = UIColor.Black;  
             baseMapLabel.UserInteractionEnabled = false;  
 
             baseMapModel.CellAccessory = UITableViewCellAccessory.DisclosureIndicator;  
             baseMapModel.CustomUI = baseMapLabel;  
             baseMapModel.CustomUIBounds = new RectangleF(rowWidth * 0.35f, 10, rowWidth * 0.6f, 30);  
             baseMapModel.RowHeight = 50;  
             baseMapRows.Add(baseMapModel);  
             optionsSource.Sections.Add(new SectionModel("Base Map Type", baseMapRows) { HeaderHeight = 30 });  
 
             Collection<RowModel> typeFilterRows = new Collection<RowModel>();  
             typeFilterModel = new RowModel(Global.FilterConfiguration.QueryColumnName + "/" + Global.FilterConfiguration.QueryColumnValue);  
             typeFilterModel.RowHeight = 50;  
             typeFilterModel.CellAccessory = UITableViewCellAccessory.DisclosureIndicator;  
             typeFilterRows.Add(typeFilterModel);  
             optionsSource.Sections.Add(new SectionModel("Filter By Type", typeFilterRows) { HeaderHeight = 30 });  
 
             Collection<RowModel> areaFilterRows = new Collection<RowModel>();  
             RowModel areaFilterModel = new RowModel("UnitType");  
             UITextView textView = new UITextView(new RectangleF(0, 0, rowWidth * 0.7f, 40));  
             textView.Font = UIFont.FromName("Arial", 16);  
             textView.Text = "20";  
             textView.Changed += DistanceChanged;  
             unitTypeButton = new UIButton(new RectangleF(rowWidth * 0.65f, 0, rowWidth * 0.3f, 40));  
             unitTypeButton.TitleLabel.TextAlignment = UITextAlignment.Right;  
             unitTypeButton.SetTitleColor(UIColor.Black, UIControlState.Normal);  
             unitTypeButton.SetTitle("Miles", UIControlState.Normal);  
             unitTypeButton.TouchUpInside += UnitTypeButtonTouchUpInside;  
 
             UIView areaView = new UIView(new RectangleF(10, 5, rowWidth, 50));  
             areaView.Add(textView);  
             areaView.Add(unitTypeButton);  
 
             areaFilterModel.CellAccessory = UITableViewCellAccessory.DisclosureIndicator;  
             areaFilterModel.CustomUI = areaView;  
             areaFilterModel.CustomUIBounds = new RectangleF(10, 5, rowWidth - 10, 30);  
             areaFilterModel.RowHeight = 50;  
             areaFilterRows.Add(areaFilterModel);  
             optionsSource.Sections.Add(new SectionModel("Buffered Distance", areaFilterRows) { HeaderHeight = 30 });  
 
             tbvOptions.Source = optionsSource;  
         }  
 
         private void UnitTypeButtonTouchUpInside(object sender, EventArgs e)  
         {  
             if (OptionRowClick != null)  
             {  
                 OptionRowClick("UnitType");  
             }  
         }  
 
         private void DistanceChanged(object sender, EventArgs e)  
         {  
             UITextView textView = (UITextView)sender;  
             Global.FilterConfiguration.BufferValue = Double.Parse(textView.Text);  
         }  
 
         private void RowClick(UITableView tableView, NSIndexPath indexPath)  
         {  
             if (OptionRowClick != null)  
             {  
                 DataTableSource source = (DataTableSource)tableView.Source;  
                 string itemName = source.Sections[indexPath.Section].Rows[indexPath.Row].Name;  
 
                 OptionRowClick(itemName);  
             }  
         }  
 
         partial void btnClose_TouchUpInside(UIButton sender)  
         {  
             DismissViewController(true, null);  
         }  
 
         partial void btnQuery_TouchUpInside(UIButton sender)  
         {  
             DismissViewController(true, null);  
             if (QueryEarthquakeResult != null)  
             {  
                 QueryEarthquakeResult();  
             }  
         }  
     }  
 }  
 
 

OptionsViewController.designer.cs

 // WARNING  
 //  
 // This file has been generated automatically by Xamarin Studio from the outlets and  
 // actions declared in your storyboard file.  
 // Manual changes to this file will not be maintained.  
 //  
 using System;  
 using Foundation;  
 using UIKit;  
 using System.CodeDom.Compiler;  
 
 namespace MapSuiteSiteSelection  
 {  
 	[Register|("OptionsViewController")]  
 	partial class OptionsViewController  
 	{  
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIButton btnClose { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIButton btnQuery { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UIView queryViewController { get; set; }  
 
 		[Outlet]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		UITableView tbvOptions { get; set; }  
 
 		[Action|("btnClose_TouchUpInside:")]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		partial void btnClose_TouchUpInside (UIButton sender);  
 
 		[Action|("btnQuery_TouchUpInside:")]  
 		[GeneratedCode|("iOS Designer", "1.0")]  
 		partial void btnQuery_TouchUpInside (UIButton sender);  
 
 		void ReleaseDesignerOutlets ()  
 		{  
 			if (btnClose != null) {  
 				btnClose.Dispose ();  
 				btnClose = null;  
 			}  
 			if (btnQuery != null) {  
 				btnQuery.Dispose ();  
 				btnQuery = null;  
 			}  
 			if (queryViewController != null) {  
 				queryViewController.Dispose ();  
 				queryViewController = null;  
 			}  
 			if (tbvOptions != null) {  
 				tbvOptions.Dispose ();  
 				tbvOptions = null;  
 			}  
 		}  
 	}  
 }  
 
 

BaseMapType.cs

 namespace MapSuiteSiteSelection  
 {  
     public enum BaseMapType  
     {  
         WorldMapKitRoad = 0,  
         WorldMapKitAerial = 1,  
         WorldMapKitAerialWithLabels = 2,  
         OpenStreetMap = 3,  
         BingMapsAerial = 4,  
         BingMapsRoad = 5  
     }  
 }  
 

DataTableSource.cs

 using System.Drawing;  
 using Foundation;  
 using UIKit;  
 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 
 namespace MapSuiteSiteSelection  
 {  
     public class DataTableSource : UITableViewSource  
     {  
         private Collection<SectionModel> sections;  
         public Action<UITableView, NSIndexPath> RowClick;  
 
         public DataTableSource()  
         {  
             this.sections = new Collection<SectionModel>();  
         }  
 
         public Collection<SectionModel> Sections  
         {  
             get { return sections; }  
         }  
 
         public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)  
         {  
             RowModel currentModel = sections[indexPath.Section].Rows[indexPath.Row];  
 
             UITableViewCell cell = tableView.DequeueReusableCell("cell") ??  
                                    new UITableViewCell(UITableViewCellStyle.Subtitle, "Cell");  
 
             switch (currentModel.CellAccessory)  
             {  
                 case UITableViewCellAccessory.Checkmark:  
                     cell.Accessory = currentModel.IsChecked ? currentModel.CellAccessory : UITableViewCellAccessory.None;  
                     break;  
                 default:  
                     cell.Accessory = currentModel.CellAccessory;  
                     break;  
             }  
 
             cell.Tag = indexPath.Row;  
             cell.TextLabel.Text = currentModel.Name;  
             cell.AccessoryView = currentModel.AccessoryView;  
 
             if (currentModel.CustomUI != null)  
             {  
                 currentModel.CustomUI.Frame = currentModel.CustomUIBounds;  
                 cell.Add(currentModel.CustomUI);  
             }  
 
             return cell;  
         }  
 
         public override nint NumberOfSections(UITableView tableView)  
         {  
             return sections.Count;  
         }  
 
         public override nint RowsInSection(UITableView tableview, nint section)  
         {  
             return sections[(int)section].Rows.Count;  
         }  
 
         public override string TitleForHeader(UITableView tableView, nint section)  
         {  
             return sections[(int)section].Title;  
         }  
 
         public override void RowSelected(UITableView tableView, NSIndexPath indexPath)  
         {  
             tableView.DeselectRow(indexPath, true);  
             if (RowClick != null) RowClick(tableView, indexPath);  
         }  
 
         public override nfloat GetHeightForHeader(UITableView tableView, nint section)  
         {  
             SectionModel currentSection = sections[(int)section];  
             if (currentSection.HeaderHeight > 0) return currentSection.HeaderHeight;  
             else return UITableView.AutomaticDimension;  
         }  
 
         public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)  
         {  
             RowModel currentModel = sections[indexPath.Section].Rows[indexPath.Row];  
             if (currentModel.RowHeight > 0) return currentModel.RowHeight;  
             else return UITableView.AutomaticDimension;  
         }  
     }  
 
     public class SectionModel  
     {  
         private Collection<RowModel> rows;  
 
         public SectionModel(string title)  
             : this(title, null)  
         { }  
 
         public SectionModel(string title, IEnumerable<RowModel> rows)  
         {  
             this.Title = title;  
             this.rows = new Collection<RowModel>();  
             if (rows != null)  
             {  
                 foreach (var item in rows)  
                 {  
                     this.rows.Add(item);  
                 }  
             }  
         }  
 
         public string Title { get; set; }  
 
         public Collection<RowModel> Rows  
         {  
             get { return rows; }  
         }  
 
         public float HeaderHeight { get; set; }  
     }  
 
     public class RowModel  
     {  
         private RectangleF customUIBounds;  
 
         public RowModel(string name)  
             : this(name, null)  
         {  
         }  
         public RowModel(string name, UIImageView accessoryView)  
         {  
             this.Name = name;  
             this.AccessoryView = accessoryView;  
         }  
         public string Name { get; set; }  
 
         public bool IsChecked { get; set; }  
 
         public UIView CustomUI { get; set; }  
 
         public RectangleF CustomUIBounds  
         {  
             get { return customUIBounds; }  
             set { customUIBounds = value; }  
         }  
 
         public float RowHeight { get; set; }  
 
         public UITableViewCellAccessory CellAccessory { get; set; }  
 
         public UIImageView AccessoryView { get; set; }  
     }  
 }  
 

FilterConfiguration.cs

 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteSiteSelection  
 {  
     public class FilterConfiguration  
     {  
         private double bufferValue;  
         private DistanceUnit bufferDistanceUnit;  
         private string queryColumnName;  
         private string queryColumnValue;  
         private FeatureLayer queryFeatureLayer;  
 
         public FilterConfiguration()  
         {  
             bufferValue = 2;  
             queryColumnName = "ROOMS";  
             queryColumnValue = Global.AllFeatureKey;  
             bufferDistanceUnit = DistanceUnit.Mile;  
         }  
 
         public double BufferValue  
         {  
             get { return bufferValue; }  
             set { bufferValue = value; }  
         }  
 
         public DistanceUnit BufferDistanceUnit  
         {  
             get { return bufferDistanceUnit; }  
             set { bufferDistanceUnit = value; }  
         }  
 
         public string QueryColumnName  
         {  
             get { return queryColumnName; }  
             set { queryColumnName = value; }  
         }  
 
         public string QueryColumnValue  
         {  
             get { return queryColumnValue; }  
             set { queryColumnValue = value; }  
         }  
 
         public FeatureLayer QueryFeatureLayer  
         {  
             get { return queryFeatureLayer; }  
             set { queryFeatureLayer = value; }  
         }  
     }  
 }  
 
 

ToolbarCandidates.cs

 using UIKit;  
 using System;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 
 namespace MapSuiteSiteSelection  
 {  
     class ToolbarCandidates : Dictionary<string, UIBarButtonItem>  
     {  
         private static ToolbarCandidates instance;  
         public event EventHandler<EventArgs> ToolBarButtonClick;  
 
         private ToolbarCandidates()  
         {  
             AddBarItem(SiteSelectionConstant.Pan, "pan.png", OnToolBarButtonClick);  
             AddBarItem(SiteSelectionConstant.Pin, "pin.png", OnToolBarButtonClick);  
             AddBarItem(SiteSelectionConstant.Clear, "recycle.png", OnToolBarButtonClick);  
             AddBarItem(SiteSelectionConstant.Search, "search.png", OnToolBarButtonClick);  
             AddBarItem(SiteSelectionConstant.Options, "options.png", OnToolBarButtonClick);  
 
             this[SiteSelectionConstant.FlexibleSpace] = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);  
         }  
 
         public static ToolbarCandidates Instance  
         {  
             get { return instance ?? (instance = new ToolbarCandidates()); }  
         }  
 
         public IEnumerable<UIBarButtonItem> GetToolBarItems()  
         {  
             Collection<UIBarButtonItem> toolBarItems = new Collection<UIBarButtonItem>();  
 
             toolBarItems.Add(Instance[SiteSelectionConstant.Pan]);  
             toolBarItems.Add(Instance[SiteSelectionConstant.Pin]);  
             toolBarItems.Add(Instance[SiteSelectionConstant.Clear]);  
             toolBarItems.Add(Instance[SiteSelectionConstant.FlexibleSpace]);  
             toolBarItems.Add(Instance[SiteSelectionConstant.Search]);  
             toolBarItems.Add(Instance[SiteSelectionConstant.Options]);  
 
             return toolBarItems;  
         }  
 
         private void AddBarItem(string title, string iconPath, EventHandler handler)  
         {  
             UIBarButtonItem item = new UIBarButtonItem(UIImage.FromBundle(iconPath), UIBarButtonItemStyle.Plain, handler);  
             item.Title = title;  
             this[title] = item;  
         }  
 
         private void OnToolBarButtonClick(object sender, EventArgs e)  
         {  
             EventHandler<EventArgs> handler = ToolBarButtonClick;  
             if (handler != null)  
             {  
                 handler(sender, e);  
             }  
         }  
     }  
 }  
 

AssemblyInfo.cs

 using System.Reflection;  
 using System.Runtime.CompilerServices;  
 using System.Runtime.InteropServices;  
 
 // 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("MapSuiteSiteSelection")]  
 [assembly: AssemblyDescription("")]  
 [assembly:|AssemblyConfiguration("")]  
 [assembly: AssemblyCompany("")]  
 [assembly:|AssemblyProduct("MapSuiteSiteSelection")]  
 [assembly: AssemblyCopyright("Copyright ©  2015")]  
 [assembly:|AssemblyTrademark("")]  
 [assembly: AssemblyCulture("")]  
 
 // Setting ComVisible to false makes the types in this assembly not visible  
 // to COM components.  If you need to access a type in this assembly from  
 // COM, set the ComVisible attribute to true on that type.  
 [assembly:|ComVisible(false)]  
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM  
 [assembly:|Guid("d3718d7c-002e-4790-b466-c89f533ecd37")]  
 
 // 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")]  
 
 

Global.cs

 using UIKit;  
 using System.Collections.Generic;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.iOSEdition;  
 
 namespace MapSuiteSiteSelection  
 {  
     public static class Global  
     {  
         public static readonly string HighlightAreaLayerKey = "HighlightAreaLayer";  
         public static readonly string HighlightMarkerLayerKey = "HighlightMarkerLayer";  
         public static readonly string HighlightCenterMarkerLayerKey = "HighlightCenterMarkerLayer";  
 
         public static readonly string SchoolsLayerKey = "SchoolsLayer";  
         public static readonly string RestaurantsLayerKey = "RestaurantsLayer";  
         public static readonly string PublicFacilitiesLayerKey = "PublicFacilitiesLayer";  
         public static readonly string MedicalFacilitiesLayerKey = "MedicalFacilitiesLayer";  
         public static readonly string HotelsLayerKey = "HotelsLayer";  
 
         public static readonly string OpenStreetMapOverlayKey = "OpenStreetMapOverlay";  
         public static readonly string BingMapsAerialOverlayKey = "BingMapsAerialOverlay";  
         public static readonly string WorldMapKitOverlayKey = "WorldMapKitOverlay";  
         public static readonly string BingMapsRoadOverlayKey = "BingMapsRoadOverlay";  
         public static readonly string HighLightOverlayKey = "HighlightOverlay";  
 
         public static readonly string AllFeatureKey = "All";  
 
         private static UIStoryboard storyboard;  
         private static Dictionary<string, UIViewController> controllers;  
 
         static Global()  
         {  
             FilterConfiguration = new FilterConfiguration();  
             controllers = new Dictionary<string, UIViewController>();  
         }  
 
         public static FilterConfiguration FilterConfiguration { get; private set; }  
 
         private static UIStoryboard Storyboard  
         {  
             get  
             {  
                 string storyboardName = UserInterfaceIdiomIsPhone ? "MainStoryboard_iPhone" : "MainStoryboard_iPad";  
                 return storyboard ?? (storyboard = UIStoryboard.FromName(storyboardName, null));  
             }  
         }  
 
         public static bool UserInterfaceIdiomIsPhone  
         {  
             get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }  
         }  
 
         public static MapView MapView { get; set; }  
 
         public static string BingMapKey { get; set; }  
 
         public static BaseMapType BaseMapType { get; set; }  
 
         public static string BaseMapTypeString { get; set; }  
 
         public static ManagedProj4Projection GetWgs84ToMercatorProjection()  
         {  
             ManagedProj4Projection wgs84ToMercatorProjection = new ManagedProj4Projection();  
             wgs84ToMercatorProjection.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString();  
             wgs84ToMercatorProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetBingMapParametersString();  
             return wgs84ToMercatorProjection;  
         }  
 
         public static UIViewController FindViewController(string viewControllerName)  
         {  
             if (!controllers.ContainsKey(viewControllerName))  
             {  
                 UIViewController controller = (UIViewController)Storyboard.InstantiateViewController(viewControllerName);  
                 controllers.Add(viewControllerName, controller);  
             }  
 
             return controllers[viewControllerName];  
         }  
 
         public static WorldMapKitOverlay WorldMapKitOverlay  
         {  
             get { return (WorldMapKitOverlay)MapView.Overlays[WorldMapKitOverlayKey]; }  
         }  
 
         public static Overlay OpenStreetMapOverlay  
         {  
             get { return MapView.Overlays[OpenStreetMapOverlayKey]; }  
         }  
 
         public static BingMapsOverlay BingMapsAerialOverlay  
         {  
             get { return (BingMapsOverlay)MapView.Overlays[BingMapsAerialOverlayKey]; }  
         }  
 
         public static BingMapsOverlay BingMapsRoadOverlay  
         {  
             get { return (BingMapsOverlay)MapView.Overlays[BingMapsRoadOverlayKey]; }  
         }  
 
         public static LayerOverlay HighLightOverlay  
         {  
             get { return (LayerOverlay)MapView.Overlays[HighLightOverlayKey]; }  
         }  
     }  
 }  
 

MapSuiteSampleHelper.cs

 using System;  
 using System.Collections.ObjectModel;  
 using CoreGraphics;  
 using UIKit;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.iOSEdition;  
 
 namespace MapSuiteSiteSelection  
 {  
     public static class MapSuiteSampleHelper  
     {  
         public static void AnimatedShow(this UIView view)  
         {  
             if (Math.Abs(view.Transform.y0) < 0.001f)  
             {  
                 nfloat y = -view.Frame.Height;  
                 UIView.Animate(0.3, () =>  
                 {  
                     view.Transform = CGAffineTransform.MakeTranslation(0, y);  
                     view.Hidden = false;  
                 });  
             }  
         }  
 
         public static void AnimatedHide(this UIView view)  
         {  
             if (Math.Abs(view.Transform.y0) > 0.001f)  
             {  
                 UIView.Animate(0.3, () =>  
                 {  
                     view.Transform = CGAffineTransform.MakeTranslation(0, 0);  
                 }, () =>  
                 {  
                     view.Hidden = true;  
                 });  
             }  
         }  
 
         public static void UpdateHighlightOverlay()  
         {  
             LayerOverlay highlightOverlay = Global.HighLightOverlay;  
 
             InMemoryFeatureLayer highlightAreaLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightAreaLayerKey];  
             InMemoryFeatureLayer highlightMarkerLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightMarkerLayerKey];  
             InMemoryFeatureLayer highlightCenterMarkerLayer = (InMemoryFeatureLayer)highlightOverlay.Layers[Global.HighlightCenterMarkerLayerKey];  
 
             if (highlightCenterMarkerLayer.InternalFeatures.Count > 0)  
             {  
                 highlightAreaLayer.InternalFeatures.Clear();  
                 highlightMarkerLayer.InternalFeatures.Clear();  
 
                 MultipolygonShape bufferResultShape = highlightCenterMarkerLayer.InternalFeatures[0].GetShape().Buffer(Global.FilterConfiguration.BufferValue, Global.MapView.MapUnit, Global.FilterConfiguration.BufferDistanceUnit);  
                 Global.FilterConfiguration.QueryFeatureLayer.Open();  
                 Collection<Feature> filterResultFeatures = Global.FilterConfiguration.QueryFeatureLayer.FeatureSource.GetFeaturesWithinDistanceOf(bufferResultShape, Global.MapView.MapUnit, DistanceUnit.Meter, 0.1, ReturningColumnsType.AllColumns);  
 
                 highlightAreaLayer.InternalFeatures.Add(new Feature(bufferResultShape));  
                 foreach (Feature feature in FilterFeaturesByColumnValue(filterResultFeatures))  
                 {  
                     highlightMarkerLayer.InternalFeatures.Add(feature);  
                 }  
 
                 highlightOverlay.Refresh();  
             }  
         }  
 
         private static Collection<Feature> FilterFeaturesByColumnValue(Collection<Feature> filterResultFeatures)  
         {  
             Collection<Feature> resultFeatures = new Collection<Feature>();  
 
             foreach (Feature feature in filterResultFeatures)  
             {  
                 if (Global.FilterConfiguration.QueryColumnValue.Equals(Global.AllFeatureKey))  
                 {  
                     resultFeatures.Add(feature);  
                 }  
                 else if (Global.FilterConfiguration.QueryColumnValue.Equals(feature.ColumnValues[Global.FilterConfiguration.QueryColumnName]))  
                 {  
                     resultFeatures.Add(feature);  
                 }  
                 else if (Global.FilterConfiguration.QueryFeatureLayer.Name.Equals(Global.HotelsLayerKey))  
                 {  
                     string[] values = Global.FilterConfiguration.QueryColumnValue.Split('~');  
                     double min = 0, max = 0, value = 0;  
                     if (double.TryParse(values[0], out min) && double.TryParse(values[1], out max)  
                         && double.TryParse(feature.ColumnValues[Global.FilterConfiguration.QueryColumnName], out value))  
                     {  
                         if (min < value && value < max)  
                         {  
                             resultFeatures.Add(feature);  
                         }  
                     }  
                 }  
             }  
 
             return resultFeatures;  
         }  
 
 
     }  
 }  
 

SiteSelectionConstant.cs

 namespace MapSuiteSiteSelection  
 {  
     public class SiteSelectionConstant  
     {  
         // Tool bar buttons  
         public const string Pan = "pan";  
         public const string Pin = "pin";  
         public const string Clear = "Clear";  
         public const string Search = "Search";  
         public const string Options = "Options";  
 
         public const string FlexibleSpace = "FlexibleSpace";  
     }  
 }