ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
using Android.App; using Android.Graphics; using Android.OS; using Android.Views; using Android.Widget; using System.IO; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; using Path = System.IO.Path; namespace MapSuiteSiteSelection { [Activity(Label|= "Site Selection", Icon = "@drawable/sampleIcon", ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.KeyboardHidden | Android.Content.PM.ConfigChanges.ScreenSize)] public class MainActivity : Activity { private RadioButton panRadioButton; private RadioButton drawPointButton; private FilterByTypeDialog filterByTypeDialog; private FilterByAreaDialog filterByAreaDialog; private SelectBaseMapTypeDialog selectBaseMapTypeDialog; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); FrameLayout mapContainer = FindViewById<FrameLayout>(Resource.Id.MapContainer); mapContainer.AddView(SampleMapView.Current, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); InitializeDialogs(); panRadioButton = FindViewById<RadioButton>(Resource.Id.PanButton); drawPointButton = FindViewById<RadioButton>(Resource.Id.DrawPointButton); Button clearButton = FindViewById<Button>(Resource.Id.ClearButton); Button searchButton = FindViewById<Button>(Resource.Id.searchButton); panRadioButton.CheckedChange += PanRadioButton_CheckedChange; drawPointButton.CheckedChange += DrawPointButton_CheckedChange; clearButton.Click += ClearButton_Click; searchButton.Click += SearchButton_Click; } private void SearchButton_Click(object sender, System.EventArgs e) { StartActivity(typeof(PotentialSimilarSitesActivity)); } private void ClearButton_Click(object sender, System.EventArgs e) { SampleMapView.Current.ClearQueryResult(); } private void DrawPointButton_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (drawPointButton.Checked) { SampleMapView.Current.TrackOverlay.TrackMode = TrackMode.Point; } } private void PanRadioButton_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (panRadioButton.Checked) { SampleMapView.Current.TrackOverlay.TrackMode = TrackMode.None; } } public override bool OnCreateOptionsMenu(IMenu menu) { menu.Add(Menu.None, Menu.First + 1, 1, "Base Map").SetIcon(Resource.Drawable.basemap); menu.Add(Menu.None, Menu.First + 2, 1, "Filter by type").SetIcon(Resource.Drawable.FilterByType); menu.Add(Menu.None, Menu.First + 3, 1, "Filter by area").SetIcon(Resource.Drawable.FilterByArea); menu.Add(Menu.None, Menu.First + 4, 1, "View Potential Similar Sites").SetIcon(Resource.Drawable.searchicon); return true; } public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Menu.First + 1: selectBaseMapTypeDialog.Show(); break; case Menu.First + 2: filterByTypeDialog.Show(); break; case Menu.First + 3: filterByAreaDialog.Show(); break; case Menu.First + 4: StartActivity(typeof(PotentialSimilarSitesActivity)); break; } return false; } private void InitializeDialogs() { selectBaseMapTypeDialog = new SelectBaseMapTypeDialog(this); filterByTypeDialog = new FilterByTypeDialog(this); filterByAreaDialog = new FilterByAreaDialog(this); } } }
using Android.App; using Android.OS; using Android.Widget; using System; using System.Collections.Generic; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { [Activity(Label|= "Potential Similar Sites", Icon = "@drawable/MapSuite", ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.KeyboardHidden | Android.Content.PM.ConfigChanges.ScreenSize)] public class PotentialSimilarSitesActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.PotentialSimilarSitesLayout); RefreshQueryResultList(); } private void RefreshQueryResultList() { TextView title = FindViewById<TextView>(Resource.Id.similarSiteTitleTextView); ListView view = FindViewById<ListView>(Resource.Id.listView); PotentialSimilarSitesAdapter adapter = view.Adapter == null ? new PotentialSimilarSitesAdapter(this) : (PotentialSimilarSitesAdapter)view.Adapter; adapter.ZoomingToFeature += Adapter_ZoomingToFeature; adapter.Data.Clear(); InMemoryFeatureLayer highlightMarkerLayer = SampleMapView.Current.FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightMarkerLayer); foreach (Feature feature in highlightMarkerLayer.InternalFeatures) { Dictionary<string, object> record = new Dictionary<string, object>(); record.Add("nameView", feature.ColumnValues["Name"]); record.Add("Feature", feature); adapter.Data.Add(record); } view.Adapter = adapter; title.Text = String.Format("Potential Similar Sites (Find {0} results)", adapter.Data.Count); } private void Adapter_ZoomingToFeature(object sender, ZoomToFeatureEventArgs e) { SampleMapView.Current.CenterAt(e.ZoomToFeature); SampleMapView.Current.ZoomToScale(SampleMapView.Current.ZoomLevelSet.ZoomLevel19.Scale); SampleMapView.Current.Refresh(); Finish(); } } }
using System.IO; namespace MapSuiteSiteSelection { internal class SampleHelper { public readonly static string AssetsDataDictionary = @"SampleData"; public readonly static string SampleDataDictionary = @"mnt/sdcard/MapSuiteSampleData/SiteSelection/"; public static string GetDataPath(params string[] fileNames) { string[] paths = new string[fileNames.Length|+ 2]; paths[0] = SampleDataDictionary; paths[1] = AssetsDataDictionary; for (int i = 0; i < fileNames.Length; i++) { paths[i|+ 2] = fileNames[i]; } return Path.Combine(paths); } } }
using Android.App; using Android.Graphics.Drawables; 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 MapSuiteSiteSelection { [Activity(Theme|= "@android:style/Theme.Light.NoTitleBar", Icon = "@drawable/sampleIcon", 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); if (!string.IsNullOrEmpty(Path.GetExtension(sourcePath)) && !File.Exists(targetPath)) { result.Add(sourcePath); } else if (string.IsNullOrEmpty(Path.GetExtension(sourcePath))) { 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++; } } } } }
namespace MapSuiteSiteSelection { public enum BaseMapType { WorldMapKitRoad = 0, WorldMapKitAerial = 1, WorldMapKitAerialWithLabels = 2, OpenStreetMap = 3, BingMapsAerial = 4, BingMapsRoad = 5 } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { internal class FilterByAreaDialog : AlertDialog { private Spinner spinner; private EditText editBufferValueText; public FilterByAreaDialog(Context context) : base(context) { View filterByAreaDialogLayout = View.Inflate(context, Resource.Layout.FilterByAreaDialogLayout, null); SetView(filterByAreaDialogLayout); spinner = filterByAreaDialogLayout.FindViewById<Spinner>(Resource.Id.distanceUnitSpinner); editBufferValueText = filterByAreaDialogLayout.FindViewById<EditText>(Resource.Id.editBufferValueText); Button cancelButton = filterByAreaDialogLayout.FindViewById<Button>(Resource.Id.CancelButton); Button okButton = filterByAreaDialogLayout.FindViewById<Button>(Resource.Id.OkButton); string[] items = new string[] { "Miles", "Kilometers" }; ArrayAdapter<string> adapter = new ArrayAdapter<string>(context, Resource.Layout.SpinnerTextViewLayout, items); spinner.Adapter = adapter; okButton.Click += OkButton_Click; cancelButton.Click += CancelButton_Click; } private void OkButton_Click(object sender, System.EventArgs e) { double bufferValue; if (double.TryParse(editBufferValueText.Text, out bufferValue)) { SampleMapView.Current.FilterConfiguration.BufferValue = bufferValue; } SampleMapView.Current.FilterConfiguration.BufferDistanceUnit = spinner.SelectedItemPosition == 0 ? DistanceUnit.Mile : DistanceUnit.Kilometer; Cancel(); SampleMapView.Current.UpdateHighlightOverlay(); } private void CancelButton_Click(object sender, System.EventArgs e) { Cancel(); } } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { internal class FilterByTypeDialog : AlertDialog { private readonly string[] poiLayerNames = new string[] { "Hotels", "Medical Facilites", "Restaurants", "Schools", "Public Facilites" }; private Context context; private string selectColumnName; private string selectColumnValue; private Collection<string> columns; private Spinner poiLayerTypeCandidatesSpinner; private FeatureLayer queryFeatureLayer; public FilterByTypeDialog(Context context) : base(context) { this.context = context; View filterByTypeDialogLayout = View.Inflate(context, Resource.Layout.FilterByTypeDialogLayout, null); SetView(filterByTypeDialogLayout); Spinner PoiLayerTypeSpinner = filterByTypeDialogLayout.FindViewById<Spinner>(Resource.Id.FeatureLayerTypeSpinner); poiLayerTypeCandidatesSpinner = filterByTypeDialogLayout.FindViewById<Spinner>(Resource.Id.ColumnTypeSpinner); Button cancelButton = filterByTypeDialogLayout.FindViewById<Button>(Resource.Id.CancelButton); Button okButton = filterByTypeDialogLayout.FindViewById<Button>(Resource.Id.OkButton); ArrayAdapter<string> adapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, poiLayerNames); PoiLayerTypeSpinner.Adapter = adapter; Collection<string> columns = GetColumnValueCandidates(0); ArrayAdapter<string> candidatesAdapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, columns); poiLayerTypeCandidatesSpinner.Adapter = candidatesAdapter; PoiLayerTypeSpinner.ItemSelected += PoiLayerTypeSpinner_ItemSelected; poiLayerTypeCandidatesSpinner.ItemSelected += PoiLayerTypeCandidatesSpinner_ItemSelected; cancelButton.Click += CancelButton_Click; okButton.Click += OkButton_Click; } private void OkButton_Click(object sender, EventArgs e) { SampleMapView.Current.FilterConfiguration.QueryColumnName = selectColumnName; SampleMapView.Current.FilterConfiguration.QueryColumnValue = selectColumnValue; SampleMapView.Current.FilterConfiguration.QueryFeatureLayer = queryFeatureLayer; Cancel(); SampleMapView.Current.UpdateHighlightOverlay(); } private void PoiLayerTypeCandidatesSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { if (columns != null) { selectColumnValue = columns[e.Position]; } } private void PoiLayerTypeSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { LayerOverlay poiOverlay = SampleMapView.Current.FindOverlay<LayerOverlay>(OverlayKey.HighlightOverlay); switch (e.Position) { case 0: queryFeatureLayer = (FeatureLayer)poiOverlay.Layers[LayerKey.HotelsLayer]; break; case 1: queryFeatureLayer = (FeatureLayer)poiOverlay.Layers[LayerKey.MedicalFacilitiesLayer]; break; case 2: queryFeatureLayer = (FeatureLayer)poiOverlay.Layers[LayerKey.RestaurantsLayer]; break; case 3: queryFeatureLayer = (FeatureLayer)poiOverlay.Layers[LayerKey.SchoolsLayer]; break; default: queryFeatureLayer = (FeatureLayer)poiOverlay.Layers[LayerKey.PublicFacilitiesLayer]; break; } columns = GetColumnValueCandidates(e.Position); ArrayAdapter<string> candidatesAdapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, columns); poiLayerTypeCandidatesSpinner.Adapter = candidatesAdapter; } private void CancelButton_Click(object sender, System.EventArgs e) { Cancel(); } public Collection<string> GetColumnValueCandidates(int selectLayerIndex) { selectColumnName = GetDefaultColumnNameByPoiType(poiLayerNames[selectLayerIndex]); Collection<string> candidates = new Collection<string>(); candidates.Add(SettingKey.AllFeature); 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 { SampleMapView.Current.FilterConfiguration.QueryFeatureLayer.Open(); IEnumerable<string> distinctColumnValues = 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; } } }
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 = SettingKey.AllFeature; 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; } } } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using Java.Net; using System; using System.Globalization; using System.IO; using System.Threading.Tasks; using System.Xml; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { public class InputBingMapKeyDialog : AlertDialog { private Context context; private View inputBingMapsKeyView; private Button bingMapsKeyOkButton; public InputBingMapKeyDialog(Context context) : base(context) { inputBingMapsKeyView = View.Inflate(context, Resource.Layout.BingMapsKeyLayout, null); this.SetView(inputBingMapsKeyView); this.context = context; EditText bingMapsKeyEditText = inputBingMapsKeyView.FindViewById<EditText>(Resource.Id.BingMapsKeyEditText); bingMapsKeyOkButton = inputBingMapsKeyView.FindViewById<Button>(Resource.Id.OkButton); Button bingMapsKeyCancelButton = inputBingMapsKeyView.FindViewById<Button>(Resource.Id.CancelButton); bingMapsKeyOkButton.Click += BingMapsKeyOkButton_Click; bingMapsKeyCancelButton.Click += BingMapsKeyCancelButton_Click; } private void BingMapsKeyOkButton_Click(object sender, EventArgs e) { EditText bingMapsKeyEditText = inputBingMapsKeyView.FindViewById<EditText>(Resource.Id.BingMapsKeyEditText); bingMapsKeyEditText.Enabled = false; bingMapsKeyOkButton.Enabled = false; Task.Factory.StartNew(() => { bool isValid = Validate(bingMapsKeyEditText.Text, BingMapsMapType.Aerial); SampleMapView.Current.Post(() => { if (isValid) { Cancel(); ISharedPreferences preferences = context.GetSharedPreferences(SettingKey.PrefsFile, 0); ISharedPreferencesEditor editor = preferences.Edit(); editor.PutString(SettingKey.PrefsBingMapKey, bingMapsKeyEditText.Text); editor.Commit(); BingMapsOverlay bingMapsAerialOverlay = SampleMapView.Current.FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsAerialOverlay); BingMapsOverlay bingMapsRoadOverlay = SampleMapView.Current.FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsRoadOverlay); bingMapsAerialOverlay.ApplicationId = bingMapsKeyEditText.Text; bingMapsRoadOverlay.ApplicationId = bingMapsKeyEditText.Text; SampleMapView.Current.SwitchBaseMapTo(SampleMapView.Current.BaseMapType); SampleMapView.Current.Refresh(); } else { bingMapsKeyEditText.Enabled = true; bingMapsKeyOkButton.Enabled = true; Toast.MakeText(context, "The input BingMapKey is not validate.", ToastLength.Long).Show(); } }); }); } private void BingMapsKeyCancelButton_Click(object sender, EventArgs e) { Cancel(); } private bool Validate(string bingMapsKey, BingMapsMapType mapType) { bool result = false; URL url = null; Stream stream = null; URLConnection conn = 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); url = new URL(loginServiceUri); conn = url.OpenConnection(); stream = conn.InputStream; 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 (url != null) url.Dispose(); if (conn != null) conn.Dispose(); if (stream != null) stream.Dispose(); } return result; } } }
using Android.Widget; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { internal class PotentialSimilarSiteResultHolder : Java.Lang.Object { public TextView NameValue { get; set; } public ImageButton IconValue { get; set; } public Feature SelectedFeature { get; set; } } }
using Android.Content; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { public class PotentialSimilarSitesAdapter : BaseAdapter { public event EventHandler<ZoomToFeatureEventArgs> ZoomingToFeature; private LayoutInflater mInflater; private List<Dictionary<string, object>> data; public PotentialSimilarSitesAdapter(Context context) { mInflater = LayoutInflater.From(context); } public List<Dictionary<string, object>> Data { get { if (data == null) { data = new List<Dictionary<string, object>>(); } return data; } } public override int Count { get { return data.Count; } } public override Java.Lang.Object GetItem(int position) { Java.Util.HashMap map = new Java.Util.HashMap(); foreach (var item in data[position]) { map.Put(item.Key, item.Value.ToString()); } return map; } public override long GetItemId(int position) { return position; } public override View GetView(int position, View convertView, ViewGroup parent) { PotentialSimilarSiteResultHolder holder = null; if (convertView == null) { holder = new PotentialSimilarSiteResultHolder(); convertView = mInflater.Inflate(Resource.Layout.ListItemTemplate, null); holder.NameValue = convertView.FindViewById<TextView>(Resource.Id.nameView); holder.IconValue = convertView.FindViewById<ImageButton>(Resource.Id.iconView); convertView.Tag = holder; holder.IconValue.Tag = holder; holder.IconValue.Click += IconValue_Click; } else { holder = (PotentialSimilarSiteResultHolder)convertView.Tag; } holder.NameValue.Text = data[position]["nameView"] as string; holder.SelectedFeature = data[position]["Feature"] as Feature; return convertView; } public void IconValue_Click(object sender, EventArgs e) { ImageButton iconButton = sender as ImageButton; PotentialSimilarSiteResultHolder holder = iconButton.Tag as PotentialSimilarSiteResultHolder; if (holder != null) { OnZoomingToFeature(new ZoomToFeatureEventArgs(holder.SelectedFeature)); } } private void OnZoomingToFeature(ZoomToFeatureEventArgs e) { if (ZoomingToFeature != null) { ZoomingToFeature(this, e); } } } }
using Android.Content; using Android.Util; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; namespace MapSuiteSiteSelection { internal class PredicateLayout : LinearLayout { Dictionary<View, Position> map = new Dictionary<View, Position>(); private readonly int dividerLine = 5; private readonly int dividerCol = 3; public PredicateLayout(Context context) : base(context) { } public PredicateLayout(Context context, int horizontalSpacing, int verticalSpacing) : base(context) { } public PredicateLayout(Context context, IAttributeSet attrs) : base(context, attrs) { } protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { int mWidth = MeasureSpec.GetSize(widthMeasureSpec); int mCount = this.ChildCount; int j = 0; int mLeft = 0; int mRight = 0; int mTop = 5; int mBottom = 0; for (int i = 0; i < mCount; i++) { View child = GetChildAt(i); child.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified); int childWidth = child.MeasuredWidth; int childHeight = child.MeasuredHeight; mRight += childWidth; Position position = new Position(); mLeft = GetPosition(i - j, i); mRight = mLeft + child.MeasuredWidth; if (mRight >= mWidth) { j = i; mLeft = this.PaddingLeft; mRight = mLeft + child.MeasuredWidth; mTop += childHeight + dividerLine; } mBottom = mTop + child.MeasuredHeight; position.Left = mLeft; position.Top = mTop; position.Right = mRight; position.Bottom = mBottom; if (!map.ContainsKey(child)) { map.Add(child, position); } } SetMeasuredDimension(mWidth, mBottom + this.PaddingBottom); } protected override void OnLayout(bool changed, int l, int t, int r, int b) { int count = this.ChildCount; for (int i = 0; i < count; i++) { View child = GetChildAt(i); Position pos = map[child]; if (pos != null) { child.Layout(pos.Left, pos.Top, pos.Right, pos.Bottom); } else { throw new Exception("MyLayout Error!"); } } } private int GetPosition(int IndexInRow, int childIndex) { if (IndexInRow > 0) { return GetPosition(IndexInRow - 1, childIndex - 1) + GetChildAt(childIndex - 1).MeasuredWidth + dividerCol; } return this.PaddingLeft; } private class Position { public int Left, Top, Right, Bottom; } } }
using Android.App; using Android.Content; using Android.Graphics; using Android.OS; using Android.Views; using System.Collections.ObjectModel; using System.IO; using System.Linq; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { public class SampleMapView : MapView { private static SampleMapView current; private BaseMapType baseMapType; private FilterConfiguration filterConfiguration; public static SampleMapView Current { get { return current ?? (current = new SampleMapView(Application.Context)); } } protected SampleMapView(Context context) : base(context) { baseMapType = BaseMapType.WorldMapKitRoad; filterConfiguration = new FilterConfiguration(); LoadOverlays(); } public BaseMapType BaseMapType { get { return baseMapType; } set { baseMapType = value; } } public FilterConfiguration FilterConfiguration { get { return filterConfiguration; } set { filterConfiguration = value; } } public void SwitchBaseMapTo(BaseMapType baseMapType) { WorldMapKitOverlay worldMapKitOverlay = FindOverlay<WorldMapKitOverlay>(OverlayKey.WorldMapKitOverlay); OpenStreetMapOverlay openStreetMapOverlay = FindOverlay<OpenStreetMapOverlay>(OverlayKey.OpenStreetMapOverlay); BingMapsOverlay bingMapsAerialOverlay = FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsAerialOverlay); BingMapsOverlay bingMapsRoadOverlay = FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsRoadOverlay); worldMapKitOverlay.IsVisible = baseMapType == BaseMapType.WorldMapKitAerial || baseMapType == BaseMapType.WorldMapKitRoad || baseMapType == BaseMapType.WorldMapKitAerialWithLabels; openStreetMapOverlay.IsVisible = baseMapType == BaseMapType.OpenStreetMap; bingMapsAerialOverlay.IsVisible = baseMapType == BaseMapType.BingMapsAerial; bingMapsRoadOverlay.IsVisible = baseMapType == BaseMapType.BingMapsRoad; switch (baseMapType) { case BaseMapType.WorldMapKitAerial: worldMapKitOverlay.MapType = WorldMapKitMapType.Aerial; break; case BaseMapType.WorldMapKitAerialWithLabels: worldMapKitOverlay.MapType = WorldMapKitMapType.AerialWithLabels; break; case BaseMapType.WorldMapKitRoad: worldMapKitOverlay.MapType = WorldMapKitMapType.Road; break; default: break; } BaseMapType = baseMapType; } public T FindOverlay<T>(string overlayKey) where T : Overlay { return (T)Overlays[overlayKey]; } public T FindFeatureLayer<T>(string layerKey) where T : FeatureLayer { foreach (var overlay in Overlays.OfType<LayerOverlay>()) { if (overlay.Layers.Contains(layerKey)) { return (T)overlay.Layers[layerKey]; } } return null; } public void ClearQueryResult() { LayerOverlay highlightOverlay = FindOverlay<LayerOverlay>(OverlayKey.HighlightOverlay); InMemoryFeatureLayer highlightAreaLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightAreaLayer); InMemoryFeatureLayer highlightMarkerLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightMarkerLayer); InMemoryFeatureLayer highlightCenterMarkerLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightCenterMarkerLayer); highlightAreaLayer.InternalFeatures.Clear(); highlightMarkerLayer.InternalFeatures.Clear(); highlightCenterMarkerLayer.InternalFeatures.Clear(); highlightOverlay.Refresh(); } public void UpdateHighlightOverlay() { LayerOverlay highlightOverlay = FindOverlay<LayerOverlay>(OverlayKey.HighlightOverlay); InMemoryFeatureLayer highlightAreaLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightAreaLayer); InMemoryFeatureLayer highlightMarkerLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightMarkerLayer); InMemoryFeatureLayer highlightCenterMarkerLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightCenterMarkerLayer); if (highlightCenterMarkerLayer.InternalFeatures.Count > 0) { highlightAreaLayer.InternalFeatures.Clear(); highlightMarkerLayer.InternalFeatures.Clear(); MultipolygonShape bufferResultShape = highlightCenterMarkerLayer.InternalFeatures[0].GetShape().Buffer(FilterConfiguration.BufferValue, MapUnit, FilterConfiguration.BufferDistanceUnit); FilterConfiguration.QueryFeatureLayer.Open(); Collection<Feature> filterResultFeatures = FilterConfiguration.QueryFeatureLayer.FeatureSource.GetFeaturesWithinDistanceOf(bufferResultShape, 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 Collection<Feature> FilterFeaturesByColumnValue(Collection<Feature> filterResultFeatures) { Collection<Feature> resultFeatures = new Collection<Feature>(); foreach (Feature feature in filterResultFeatures) { if (filterConfiguration.QueryColumnValue.Equals(SettingKey.AllFeature)) { resultFeatures.Add(feature); } else if (filterConfiguration.QueryColumnValue.Equals(feature.ColumnValues[filterConfiguration.QueryColumnName])) { resultFeatures.Add(feature); } else if (filterConfiguration.QueryFeatureLayer.Name.Equals(LayerKey.HotelsLayer)) { string[] values = 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[filterConfiguration.QueryColumnName], out value)) { if (min < value && value < max) { resultFeatures.Add(feature); } } } } return resultFeatures; } private void TrackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e) { if (TrackOverlay.TrackShapeLayer.InternalFeatures.Count > 0) { Feature centerFeature = TrackOverlay.TrackShapeLayer.InternalFeatures[0]; TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); InMemoryFeatureLayer highlightCenterMarkerLayer = FindFeatureLayer<InMemoryFeatureLayer>(LayerKey.HighlightCenterMarkerLayer); highlightCenterMarkerLayer.InternalFeatures.Clear(); highlightCenterMarkerLayer.InternalFeatures.Add(centerFeature); UpdateHighlightOverlay(); } } private void LoadOverlays() { //Highlight Overlay GeoImage pinImage = GetGeoImageFromImageId(Resource.Drawable.drawPoint); 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(GetGeoImageFromImageId(Resource.Drawable.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; //LimitPolygon ShapeFileFeatureLayer limitPolygonLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("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 = GetWgs84ToMercatorProjection(); // Poi Overlay ShapeFileFeatureLayer hotelsLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("POIs", "Hotels.shp")); hotelsLayer.Name = LayerKey.HotelsLayer; hotelsLayer.Transparency = 120f; hotelsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.Hotel)); hotelsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; hotelsLayer.FeatureSource.Projection = GetWgs84ToMercatorProjection(); ShapeFileFeatureLayer medicalFacilitesLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("POIs", "Medical_Facilities.shp")); medicalFacilitesLayer.Name = LayerKey.MedicalFacilitiesLayer; medicalFacilitesLayer.Transparency = 120f; medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.DrugStore)); medicalFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; medicalFacilitesLayer.FeatureSource.Projection = GetWgs84ToMercatorProjection(); ; ShapeFileFeatureLayer publicFacilitesLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("POIs", "Public_Facilities.shp")); publicFacilitesLayer.Name = LayerKey.PublicFacilitiesLayer; publicFacilitesLayer.Transparency = 120f; publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.public_facility)); publicFacilitesLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; publicFacilitesLayer.FeatureSource.Projection = GetWgs84ToMercatorProjection(); ShapeFileFeatureLayer restaurantsLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("POIs", "Restaurants.shp")); restaurantsLayer.Name = LayerKey.RestaurantsLayer; restaurantsLayer.Transparency = 120f; restaurantsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.restaurant)); restaurantsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; restaurantsLayer.FeatureSource.Projection = GetWgs84ToMercatorProjection(); ShapeFileFeatureLayer schoolsLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath("POIs", "Schools.shp")); schoolsLayer.Name = LayerKey.SchoolsLayer; schoolsLayer.Transparency = 120f; schoolsLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.school)); schoolsLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; schoolsLayer.FeatureSource.Projection = GetWgs84ToMercatorProjection(); LayerOverlay highlightOverlay = new LayerOverlay(); highlightOverlay.TileType = TileType.SingleTile; highlightOverlay.Layers.Add(limitPolygonLayer); highlightOverlay.Layers.Add(LayerKey.HotelsLayer, hotelsLayer); highlightOverlay.Layers.Add(LayerKey.MedicalFacilitiesLayer, medicalFacilitesLayer); highlightOverlay.Layers.Add(LayerKey.PublicFacilitiesLayer, publicFacilitesLayer); highlightOverlay.Layers.Add(LayerKey.RestaurantsLayer, restaurantsLayer); highlightOverlay.Layers.Add(LayerKey.SchoolsLayer, schoolsLayer); highlightOverlay.Layers.Add(LayerKey.HighlightAreaLayer, highlightAreaLayer); highlightOverlay.Layers.Add(LayerKey.HighlightMarkerLayer, highlightMarkerLayer); highlightOverlay.Layers.Add(LayerKey.HighlightCenterMarkerLayer, highlightCenterMarkerLayer); string baseFolder = Environment.ExternalStorageDirectory.AbsolutePath; string cachePathFilename = System.IO.Path.Combine(baseFolder, "MapSuiteTileCaches/SampleCaches.db"); // OSM OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay(); osmOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "OSMSphericalMercator"); osmOverlay.IsVisible = false; // WMK WorldMapKitOverlay wmkOverlay = new WorldMapKitOverlay(); wmkOverlay.Projection = WorldMapKitProjection.SphericalMercator; // Bing - Aerial BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay(); bingMapsAerialOverlay.IsVisible = false; bingMapsAerialOverlay.MapType = BingMapsMapType.AerialWithLabels; bingMapsAerialOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "BingAerialWithLabels"); // Bing - Road BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay(); bingMapsRoadOverlay.IsVisible = false; bingMapsRoadOverlay.MapType = BingMapsMapType.Road; bingMapsRoadOverlay.TileCache = new SqliteBitmapTileCache(cachePathFilename, "BingRoad"); //Maps SetBackgroundColor(Color.Argb(255, 244, 242, 238)); MapUnit = GeographyUnit.Meter; MapTools.ZoomMapTool.Visibility = ViewStates.Invisible; ZoomLevelSet = new BingMapsZoomLevelSet(); CurrentExtent = new RectangleShape(-10789390.0630888, 3924457.19413373, -10768237.5787263, 3906066.41190523); Overlays.Add(OverlayKey.OpenStreetMapOverlay, osmOverlay); Overlays.Add(OverlayKey.WorldMapKitOverlay, wmkOverlay); Overlays.Add(OverlayKey.BingMapsAerialOverlay, bingMapsAerialOverlay); Overlays.Add(OverlayKey.BingMapsRoadOverlay, bingMapsRoadOverlay); Overlays.Add(OverlayKey.HighlightOverlay, highlightOverlay); FilterConfiguration.QueryFeatureLayer = hotelsLayer; TrackOverlay.TrackEnded += TrackOverlay_TrackEnded; } private ManagedProj4Projection GetWgs84ToMercatorProjection() { ManagedProj4Projection wgs84ToMercatorProjection = new ManagedProj4Projection(); wgs84ToMercatorProjection.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString(); wgs84ToMercatorProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetBingMapParametersString(); return wgs84ToMercatorProjection; } private GeoImage GetGeoImageFromImageId(int imageId) { MemoryStream ms = new MemoryStream(); BitmapFactory.DecodeResource(this.Resources, imageId).Compress(Bitmap.CompressFormat.Png, 100, ms); return new GeoImage(ms); } } public static class OverlayKey { public const string OpenStreetMapOverlay = "OpenStreetMapOverlay"; public const string BingMapsAerialOverlay = "BingMapsAerialOverlay"; public const string WorldMapKitOverlay = "WorldMapKitOverlay"; public const string BingMapsRoadOverlay = "BingMapsRoadOverlay"; public const string HighlightOverlay = "HighlightOverlay"; } public static class LayerKey { public const string HighlightAreaLayer = "HighlightAreaLayer"; public const string HighlightMarkerLayer = "HighlightMarkerLayer"; public const string HighlightCenterMarkerLayer = "HighlightCenterMarkerLayer"; public const string SchoolsLayer = "SchoolsLayer"; public const string RestaurantsLayer = "RestaurantsLayer"; public const string PublicFacilitiesLayer = "PublicFacilitiesLayer"; public const string MedicalFacilitiesLayer = "MedicalFacilitiesLayer"; public const string HotelsLayer = "HotelsLayer"; } public static class SettingKey { public const string AllFeature = "All"; public const string PrefsBingMapKey = "BingMapKey"; public const string PrefsFile = "SamplePrefsFile"; } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using System; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { public class SelectBaseMapTypeDialog : AlertDialog { private View selectBaseMapTypeView; private string tempBaseMap; private Context context; private Button baseMapOkButton; private Button baseMapCancelButton; private RadioButton wmkRoadRadioButton; private RadioButton wmkAerialRadioButton; private RadioButton wmkAerialWithLabelsRadioButton; private RadioButton osmRadioButton; private RadioButton bingaRadioButton; private RadioButton bingrRadioButton; public SelectBaseMapTypeDialog(Context context) : base(context) { this.context = context; selectBaseMapTypeView = View.Inflate(context, Resource.Layout.SelectBaseMapTypeLayout, null); this.SetView(selectBaseMapTypeView); wmkRoadRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.wmkRoadRadioButton); wmkAerialRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.wmkAerialRadioButton); wmkAerialWithLabelsRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.wmkAerialWithLabelsRadioButton); osmRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.osmRadioButton); bingaRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.bingaRadioButton); bingrRadioButton = selectBaseMapTypeView.FindViewById<RadioButton>(Resource.Id.bingrRadioButton); wmkRoadRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; wmkAerialRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; wmkAerialWithLabelsRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; osmRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; bingaRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; bingrRadioButton.CheckedChange += BaseMapRadioButton_CheckedChange; baseMapOkButton = selectBaseMapTypeView.FindViewById<Button>(Resource.Id.OkButton); baseMapCancelButton = selectBaseMapTypeView.FindViewById<Button>(Resource.Id.CancelButton); baseMapOkButton.Click += BaseMapOkButton_Click; baseMapCancelButton.Click += (sender, args) => Cancel(); } private void BaseMapRadioButton_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { RadioButton radioButton = (RadioButton)sender; if (radioButton.Checked) { tempBaseMap = radioButton.Text; } } public override void Show() { RefreshBaseMapTypeControls(); base.Show(); } private void RefreshBaseMap() { BaseMapType mapType; string baseMapTypeString = tempBaseMap.Replace(" ", ""); if (Enum.TryParse(baseMapTypeString, true, out mapType)) { if (mapType == BaseMapType.BingMapsAerial || mapType == BaseMapType.BingMapsRoad) { ISharedPreferences preferences = context.GetSharedPreferences(SettingKey.PrefsFile, 0); string result = preferences.GetString(SettingKey.PrefsBingMapKey, string.Empty); if (!string.IsNullOrEmpty(result)) { SampleMapView.Current.FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsAerialOverlay).ApplicationId = result; SampleMapView.Current.FindOverlay<BingMapsOverlay>(OverlayKey.BingMapsRoadOverlay).ApplicationId = result; SampleMapView.Current.SwitchBaseMapTo(mapType); } else { SampleMapView.Current.BaseMapType = mapType; InputBingMapKeyDialog dialog = new InputBingMapKeyDialog(context); dialog.Show(); } } else { SampleMapView.Current.SwitchBaseMapTo(mapType); } } } private void BaseMapOkButton_Click(object sender, EventArgs e) { RefreshBaseMap(); Cancel(); } private void RefreshBaseMapTypeControls() { switch (SampleMapView.Current.BaseMapType) { case BaseMapType.WorldMapKitRoad: wmkRoadRadioButton.Checked = true; break; case BaseMapType.WorldMapKitAerial: wmkAerialRadioButton.Checked = true; break; case BaseMapType.WorldMapKitAerialWithLabels: wmkAerialWithLabelsRadioButton.Checked = true; break; case BaseMapType.OpenStreetMap: osmRadioButton.Checked = true; break; case BaseMapType.BingMapsRoad: bingrRadioButton.Checked = true; break; case BaseMapType.BingMapsAerial: bingaRadioButton.Checked = true; break; default: break; } } } }
using System; using ThinkGeo.MapSuite.Core; namespace MapSuiteSiteSelection { public class ZoomToFeatureEventArgs : EventArgs { public ZoomToFeatureEventArgs() : this(null) { } public ZoomToFeatureEventArgs(Feature feature) : base() { ZoomToFeature = feature; } public Feature ZoomToFeature { get; set; } } }
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("MapSuiteSiteSelection")] [assembly: AssemblyDescription("")] [assembly:|AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly:|AssemblyProduct("MapSuiteSiteSelection")] [assembly: AssemblyCopyright("Copyright © 2015")] [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")]
#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("MapSuiteSiteSelection.Resource", IsApplication=true)] namespace MapSuiteSiteSelection { [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::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_default256x256; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_default512x512 = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_default512x512; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_globe; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe_Pressed = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_globe_Pressed; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_Minus; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus_Pressed = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_Minus_Pressed; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_noImageTile = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_noImageTile; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_Plus; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus_Pressed = global::MapSuiteSiteSelection.Resource.Drawable.icon_mapsuite_Plus_Pressed; } public partial class Attribute { static Attribute() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Attribute() { } } public partial class Drawable { // aapt resource value: 0x7f020000 public const int basemap = 2130837504; // aapt resource value: 0x7f020001 public const int clear = 2130837505; // aapt resource value: 0x7f020002 public const int displaytype_bing_aerial = 2130837506; // aapt resource value: 0x7f020003 public const int displaytype_bing_road = 2130837507; // aapt resource value: 0x7f020004 public const int displaytype_osm = 2130837508; // aapt resource value: 0x7f020005 public const int displaytype_wmk = 2130837509; // aapt resource value: 0x7f020006 public const int drawPoint = 2130837510; // aapt resource value: 0x7f020007 public const int DrugStore = 2130837511; // aapt resource value: 0x7f020008 public const int FilterByArea = 2130837512; // aapt resource value: 0x7f020009 public const int FilterByType = 2130837513; // aapt resource value: 0x7f02000a public const int find = 2130837514; // aapt resource value: 0x7f02000b public const int Hotel = 2130837515; // aapt resource value: 0x7f02000c public const int Icon = 2130837516; // aapt resource value: 0x7f02000d public const int icon_mapsuite_default256x256 = 2130837517; // aapt resource value: 0x7f02000e public const int icon_mapsuite_default512x512 = 2130837518; // aapt resource value: 0x7f02000f public const int icon_mapsuite_globe = 2130837519; // aapt resource value: 0x7f020010 public const int icon_mapsuite_globe_Pressed = 2130837520; // aapt resource value: 0x7f020011 public const int icon_mapsuite_Minus = 2130837521; // aapt resource value: 0x7f020012 public const int icon_mapsuite_Minus_Pressed = 2130837522; // aapt resource value: 0x7f020013 public const int icon_mapsuite_noImageTile = 2130837523; // aapt resource value: 0x7f020014 public const int icon_mapsuite_Plus = 2130837524; // aapt resource value: 0x7f020015 public const int icon_mapsuite_Plus_Pressed = 2130837525; // aapt resource value: 0x7f020016 public const int linearlayoutStyle = 2130837526; // aapt resource value: 0x7f020017 public const int MapSuite = 2130837527; // aapt resource value: 0x7f020018 public const int pan = 2130837528; // aapt resource value: 0x7f020019 public const int public_facility = 2130837529; // aapt resource value: 0x7f02001a public const int restaurant = 2130837530; // aapt resource value: 0x7f02001b public const int school = 2130837531; // aapt resource value: 0x7f02001c public const int searchicon = 2130837532; // aapt resource value: 0x7f02001d public const int selectedHalo = 2130837533; static Drawable() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Drawable() { } } public partial class Id { // aapt resource value: 0x7f050001 public const int BingMapsKeyEditText = 2131034113; // aapt resource value: 0x7f050003 public const int CancelButton = 2131034115; // aapt resource value: 0x7f050011 public const int ClearButton = 2131034129; // aapt resource value: 0x7f050009 public const int ColumnTypeSpinner = 2131034121; // aapt resource value: 0x7f050010 public const int DrawPointButton = 2131034128; // aapt resource value: 0x7f050008 public const int FeatureLayerTypeSpinner = 2131034120; // aapt resource value: 0x7f050002 public const int OkButton = 2131034114; // aapt resource value: 0x7f05000f public const int PanButton = 2131034127; // aapt resource value: 0x7f05000d public const int ToolsLinearLayout = 2131034125; // aapt resource value: 0x7f05000c public const int androidMap = 2131034124; // aapt resource value: 0x7f050019 public const int bingaRadioButton = 2131034137; // aapt resource value: 0x7f05001a public const int bingrRadioButton = 2131034138; // aapt resource value: 0x7f050004 public const int bufferAreaRadioButton = 2131034116; // aapt resource value: 0x7f050005 public const int bufferLineBreakLayout = 2131034117; // aapt resource value: 0x7f050007 public const int distanceUnitSpinner = 2131034119; // aapt resource value: 0x7f050006 public const int editBufferValueText = 2131034118; // aapt resource value: 0x7f05000a public const int iconView = 2131034122; // aapt resource value: 0x7f050014 public const int listView = 2131034132; // aapt resource value: 0x7f05000b public const int nameView = 2131034123; // aapt resource value: 0x7f050018 public const int osmRadioButton = 2131034136; // aapt resource value: 0x7f05000e public const int radioGroup1 = 2131034126; // aapt resource value: 0x7f050012 public const int searchButton = 2131034130; // aapt resource value: 0x7f050013 public const int similarSiteTitleTextView = 2131034131; // aapt resource value: 0x7f050000 public const int textView1 = 2131034112; // aapt resource value: 0x7f05001c public const int uploadDataTextView = 2131034140; // aapt resource value: 0x7f05001b public const int uploadProgressBar = 2131034139; // aapt resource value: 0x7f050016 public const int wmkAerialRadioButton = 2131034134; // aapt resource value: 0x7f050017 public const int wmkAerialWithLabelsRadioButton = 2131034135; // aapt resource value: 0x7f050015 public const int wmkRoadRadioButton = 2131034133; static Id() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Id() { } } public partial class Layout { // aapt resource value: 0x7f030000 public const int BingMapsKeyLayout = 2130903040; // aapt resource value: 0x7f030001 public const int FilterByAreaDialogLayout = 2130903041; // aapt resource value: 0x7f030002 public const int FilterByTypeDialogLayout = 2130903042; // aapt resource value: 0x7f030003 public const int ListItemTemplate = 2130903043; // aapt resource value: 0x7f030004 public const int Main = 2130903044; // aapt resource value: 0x7f030005 public const int PotentialSimilarSitesLayout = 2130903045; // aapt resource value: 0x7f030006 public const int RadioButtonTextColorSelector = 2130903046; // aapt resource value: 0x7f030007 public const int RadioButtonTextSizeSelector = 2130903047; // aapt resource value: 0x7f030008 public const int SelectBaseMapTypeLayout = 2130903048; // aapt resource value: 0x7f030009 public const int SpinnerTextViewLayout = 2130903049; // aapt resource value: 0x7f03000a public const int SplashLayout = 2130903050; static Layout() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Layout() { } } public partial class String { // aapt resource value: 0x7f040001 public const int ApplicationName = 2130968577; // aapt resource value: 0x7f040009 public const int BufferDistance = 2130968585; // aapt resource value: 0x7f040005 public const int Clear = 2130968581; // aapt resource value: 0x7f040000 public const int Hello = 2130968576; // aapt resource value: 0x7f040008 public const int MinutesDriving = 2130968584; // aapt resource value: 0x7f040006 public const int Option = 2130968582; // aapt resource value: 0x7f040002 public const int Pan = 2130968578; // aapt resource value: 0x7f040004 public const int Pin = 2130968580; // aapt resource value: 0x7f040007 public const int ServiceAreaIn = 2130968583; // aapt resource value: 0x7f04000a public const int TypeText = 2130968586; // aapt resource value: 0x7f040003 public const int ZoomTo = 2130968579; static String() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private String() { } } } } #pragma warning restore 1591