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.Content; using Android.Content.Res; using Android.Graphics; using Android.Locations; using Android.OS; using Android.Util; using Android.Views; using Android.Views.Animations; using Android.Widget; using System; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace GettingStartedSample { /// <summary> /// This class represents the main window. /// </summary> [Activity(Label|= "Getting Started", MainLauncher = true, ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.KeyboardHidden | Android.Content.PM.ConfigChanges.ScreenSize)] public class MainActivity : Activity, ILocationListener { private bool isTracking; private float locationAccuracy; private string bestGpsProvider; private MapView mapView; private Marker locationMarker; private MarkerOverlay gpsOverlay; private PopupOverlay popupOverlay; private Animation toolsBarOutAnimation; private Animation toolsBarInAnimation; private LocationManager locationManager; private Proj4Projection wgs84ToMeterProjection; private ScaleZoomLevelMapTool scaleZoomLevelMapTool; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); //Initialize the Map and relative information. InitializeGlobalVariables(); InitializeAndroidMap(); InitializeAnimations(); LinearLayout toolsBarHeaderLayout = FindViewById<LinearLayout>(Resource.Id.ToolsBarHeaderLayout); ImageButton locationImageButon = FindViewById<ImageButton>(Resource.Id.locationImageButton); ImageButton fullExtentImageButton = FindViewById<ImageButton>(Resource.Id.fullextImageButton); ImageButton previousImageButton = FindViewById<ImageButton>(Resource.Id.preextImageButton); ImageButton nextImageButton = FindViewById<ImageButton>(Resource.Id.nxtextImageButton); ImageButton infoImageButton = FindViewById<ImageButton>(Resource.Id.infoImageButton); //Register the events for controls. toolsBarHeaderLayout.Click += ToolsBarHeaderLayoutClick; locationImageButon.Click += LocationImageButtonClick; fullExtentImageButton.Click += FullExtentImageButtonClick; previousImageButton.Click += PreviousImageButtonClick; nextImageButton.Click += NextImageButtonClick; infoImageButton.Click += InfoImageButtonClick; RefreshToolsBarWithConfig(Resources.Configuration); CheckGpsServiceAndOpenSettings(); } /// <summary> /// Called by the system when the device configuration changes while your /// activity is running. /// </summary> /// <param name="newConfig">The new device configuration.</param> public override void OnConfigurationChanged(Configuration newConfig) { FrameLayout toolsBarBorderLayout = FindViewById<FrameLayout>(Resource.Id.ToolsBarBorderFrameLayout); bool isVisible = toolsBarBorderLayout.Visibility == ViewStates.Visible; RefreshToolsBarWithConfig(newConfig); base.OnConfigurationChanged(newConfig); float centerCoordinateToolHeight = isVisible ? mapView.MapTools.CenterCoordinate.GetY() : mapView.MapTools.CenterCoordinate.GetY() - 50 * MapView.DisplayDensity; mapView.MapTools.CenterCoordinate.SetY(centerCoordinateToolHeight); float scaleZoomLevelMapToolHeight = isVisible ? scaleZoomLevelMapTool.GetY() : scaleZoomLevelMapTool.GetY() - 50 * MapView.DisplayDensity; scaleZoomLevelMapTool.SetY(scaleZoomLevelMapToolHeight); if (newConfig.Orientation == Android.Content.Res.Orientation.Portrait) { mapView.MapTools.CenterCoordinate.SetY(mapView.MapTools.CenterCoordinate.GetY() - 30 * MapView.DisplayDensity); scaleZoomLevelMapTool.SetY(scaleZoomLevelMapTool.GetY() - 30 * MapView.DisplayDensity); } else if (newConfig.Orientation == Android.Content.Res.Orientation.Landscape) { mapView.MapTools.CenterCoordinate.SetY(mapView.MapTools.CenterCoordinate.GetY() + 30 * MapView.DisplayDensity); scaleZoomLevelMapTool.SetY(scaleZoomLevelMapTool.GetY() + 30 * MapView.DisplayDensity); } } /// <summary> /// Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. /// </summary> /// <param name="requestCode">The integer request code originally supplied to /// startActivityForResult(), allowing you to identify who this /// result came from.</param> /// <param name="resultCode">The integer result code returned by the child activity /// through its setResult().</param> /// <param name="data">An Intent, which can return result data to the caller /// (various data can be attached to Intent "extras").</param> protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (requestCode == 100) { if (CheckGpsService()) { StartGpsTracking(); RefreshGpsLocation(locationManager.GetLastKnownLocation(bestGpsProvider)); } } base.OnActivityResult(requestCode, resultCode, data); } public void OnLocationChanged(Location location) { RefreshGpsLocation(location); } public void OnProviderDisabled(string provider) { RefreshGpsLocation(null); } public void OnProviderEnabled(string provider) { RefreshGpsLocation(locationManager.GetLastKnownLocation(provider)); } public void OnStatusChanged(string provider, Availability status, Bundle extras) { switch (status) { case Availability.OutOfService: Toast.MakeText(this, "Out Of Service!", ToastLength.Long); break; case Availability.TemporarilyUnavailable: Toast.MakeText(this, "Pause the Gps service!", ToastLength.Long); break; } } private void InfoImageButtonClick(object sender, EventArgs e) { StartActivity(typeof(InfoActivity)); } private void NextImageButtonClick(object sender, EventArgs e) { mapView.ZoomToNextExtent(); } private void PreviousImageButtonClick(object sender, EventArgs e) { mapView.ZoomToPreviousExtent(); } private void FullExtentImageButtonClick(object sender, EventArgs e) { mapView.CurrentExtent = mapView.Overlays["WorldMapKitOverlay"].GetBoundingBox(); mapView.Refresh(); } private void LocationImageButtonClick(object sender, EventArgs e) { if (locationMarker != null) mapView.ZoomTo(locationMarker.Position, mapView.ZoomLevelSet.ZoomLevel15.Scale); } private void ToolsBarHeaderLayoutClick(object sender, EventArgs e) { LinearLayout toolsBarLayout = FindViewById<LinearLayout>(Resource.Id.ToolsBarLinearLayout); FrameLayout toolsBarBorderLayout = FindViewById<FrameLayout>(Resource.Id.ToolsBarBorderFrameLayout); bool isVisible = toolsBarBorderLayout.Visibility == ViewStates.Visible; float centerCoordinateToolHeight = isVisible ? mapView.MapTools.CenterCoordinate.GetY() + 50 * MapView.DisplayDensity : mapView.MapTools.CenterCoordinate.GetY() - 50 * MapView.DisplayDensity; mapView.MapTools.CenterCoordinate.SetY(centerCoordinateToolHeight); float scaleZoomLevelMapToolHeight = isVisible ? scaleZoomLevelMapTool.GetY() + 50 * MapView.DisplayDensity : scaleZoomLevelMapTool.GetY() - 50 * MapView.DisplayDensity; scaleZoomLevelMapTool.SetY(scaleZoomLevelMapToolHeight); if (isVisible) { toolsBarLayout.StartAnimation(toolsBarOutAnimation); } else { toolsBarLayout.StartAnimation(toolsBarInAnimation); } toolsBarBorderLayout.Visibility = ViewStates.Invisible; } private void mapView_MapSingleTap(object sender, MotionEvent e) { Popup popup = CreateNewPopup(e); popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); popupOverlay.Refresh(); } private void mapView_MapDoubleTap(object sender, MotionEvent e) { mapView.ZoomInByAnchorPoint(new ScreenPointF(e.GetX(), e.GetY())); } private void mapView_MapLongPress(object sender, MotionEvent e) { SelectZoomLevelListDialog selectZoomLevelDialog = new SelectZoomLevelListDialog(this, mapView); selectZoomLevelDialog.Show(); selectZoomLevelDialog.CancelEvent += selectZoomLevelDialogCancelEvent; } private void mapView_CurrentScaleChanged(object sender, CurrentScaleChangedMapViewEventArgs e) { if (locationMarker != null) { double mapResolution = Math.Max(mapView.CurrentExtent.Width / mapView.Width, mapView.CurrentExtent.Height / mapView.Height); int radius = (int)(locationAccuracy / mapResolution); ((GpsMarker)locationMarker).AccuracyRadius = radius; } } private void selectZoomLevelDialogCancelEvent(object sender, EventArgs e) { SelectZoomLevelListDialog dialog = (SelectZoomLevelListDialog)sender; if (dialog.CurrentZoomLevel != null) { mapView.ZoomToScale(dialog.CurrentZoomLevel.Scale); } } private void StartGpsTracking() { if (!isTracking) { isTracking = true; locationManager.RequestLocationUpdates(bestGpsProvider, 5 * 1000, 5, this); } } /// <summary> /// Creates the new popup. /// </summary> /// <param name="e">The Motion Event.</param> /// <returns>Returns the Popup.</returns> private Popup CreateNewPopup(MotionEvent e) { Popup popup = new Popup(this); PointF location = new PointF(e.GetX(), e.GetY()); popup.Position = ExtentHelper.ToWorldCoordinate(mapView.CurrentExtent, location.X, location.Y, (float)mapView.Width, (float)mapView.Height); TextView textView = new TextView(this); PointShape locationShape = wgs84ToMeterProjection.ConvertToInternalProjection(popup.Position) as PointShape; textView.Text = string.Format("X : {0:N2}" + "\r\n" + "Y : {1:N2}", locationShape.X, locationShape.Y); textView.SetTextColor(Color.Black); textView.SetTextSize(ComplexUnitType.Px, 30); LinearLayout.LayoutParams btnLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); btnLayoutParams.Gravity = GravityFlags.CenterVertical; ImageButton button = new ImageButton(this); button.LayoutParameters = btnLayoutParams; button.SetBackgroundResource(Resource.Layout.ButtonBackgroundSelector); button.SetImageResource(Resource.Drawable.close); button.Click += (s, clickEvent) => { popupOverlay.Popups.Clear(); popupOverlay.Refresh(); }; LinearLayout linearLayout = new LinearLayout(this); linearLayout.SetPadding(8, 0, 0, 0); linearLayout.Orientation = Android.Widget.Orientation.Horizontal; linearLayout.SetGravity(GravityFlags.CenterHorizontal); linearLayout.AddView(textView); linearLayout.AddView(button); popup.AddView(linearLayout); return popup; } /// <summary> /// Refreshes the GPS marker when location is updated. /// </summary> /// <param name="gpsLocation">The GPS location.</param> private void RefreshGpsLocation(Location gpsLocation) { if (gpsLocation != null) { PointShape location = new PointShape(gpsLocation.Longitude, gpsLocation.Latitude); location = wgs84ToMeterProjection.ConvertToExternalProjection(location) as PointShape; locationAccuracy = gpsLocation.Accuracy; if (locationMarker == null) { locationMarker = new GpsMarker(this); gpsOverlay.Markers.Add(locationMarker); } double mapResolution = Math.Max(mapView.CurrentExtent.Width / mapView.Width, mapView.CurrentExtent.Height / mapView.Height); int radius = (int)(gpsLocation.Accuracy / mapResolution); ((GpsMarker)locationMarker).AccuracyRadius = radius; locationMarker.Position = location; if (mapView.Width != 0 && mapView.Height != 0) { mapView.CenterAt(location); } } } /// <summary> /// Refreshes the tools bar with configuration changes. /// </summary> /// <param name="newConfig">The new configuration.</param> private void RefreshToolsBarWithConfig(Configuration newConfig) { LinearLayout toolsBarButtonsLayout = FindViewById<LinearLayout>(Resource.Id.ToolButtonsLayout); LinearLayout toolsBarHeaderLayout = FindViewById<LinearLayout>(Resource.Id.ToolsBarHeaderLayout); FrameLayout toolsBarBorderFrameLayout = FindViewById<FrameLayout>(Resource.Id.ToolsBarBorderFrameLayout); ImageButton infoButton = FindViewById<ImageButton>(Resource.Id.infoImageButton); TextView landscapeTextView = FindViewById<TextView>(Resource.Id.landscapeTextView); // If the Orientation is Portrait, refresh the layout for the new configuration. if (newConfig.Orientation == Android.Content.Res.Orientation.Portrait) { landscapeTextView.Visibility = ViewStates.Gone; toolsBarHeaderLayout.Visibility = ViewStates.Visible; FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.FillParent); lp.Gravity = GravityFlags.Left; FrameLayout.LayoutParams rightLp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); rightLp.Gravity = GravityFlags.Right; if (toolsBarButtonsLayout.FindViewById(Resource.Id.infoImageButton) == infoButton) { toolsBarButtonsLayout.RemoveView(infoButton); toolsBarBorderFrameLayout.AddView(infoButton); infoButton.LayoutParameters = rightLp; } toolsBarButtonsLayout.LayoutParameters = lp; } // If the Orientation is Landscape, refresh the layout for the new configuration. else if (newConfig.Orientation == Android.Content.Res.Orientation.Landscape) { landscapeTextView.Visibility = ViewStates.Visible; toolsBarHeaderLayout.Visibility = ViewStates.Gone; toolsBarBorderFrameLayout.Visibility = ViewStates.Visible; FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.FillParent); lp.Gravity = GravityFlags.Right; if (toolsBarButtonsLayout.FindViewById(Resource.Id.infoImageButton) != infoButton) { toolsBarBorderFrameLayout.RemoveView(infoButton); toolsBarButtonsLayout.AddView(infoButton); } toolsBarButtonsLayout.LayoutParameters = lp; } } /// <summary> /// Initializes the global variables. /// </summary> private void InitializeGlobalVariables() { Criteria criteria = new Criteria(); criteria.Accuracy = Accuracy.Coarse; criteria.PowerRequirement = Power.Low; criteria.AltitudeRequired = false; criteria.BearingRequired = false; criteria.SpeedRequired = false; criteria.CostAllowed = true; isTracking = false; locationManager = (LocationManager)GetSystemService(Context.LocationService); bestGpsProvider = locationManager.GetBestProvider(criteria, true); wgs84ToMeterProjection = new Proj4Projection(); wgs84ToMeterProjection.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString(); wgs84ToMeterProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString(); wgs84ToMeterProjection.Open(); } /// <summary> /// Initializes the android map. /// </summary> private void InitializeAndroidMap() { mapView = FindViewById<MapView>(Resource.Id.androidMap); mapView.MapUnit = GeographyUnit.Meter; mapView.ZoomLevelSet = new BingMapsZoomLevelSet(); mapView.CurrentExtent = new RectangleShape(-19062735.6816748, 9273256.52450252, -5746827.16371793, 2673516.56066139); mapView.SetBackgroundColor(new Color(255, 244, 242, 238)); WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay(); worldMapKitOverlay.Projection = WorldMapKitProjection.SphericalMercator; mapView.Overlays.Add("WorldMapKitOverlay", worldMapKitOverlay); gpsOverlay = new MarkerOverlay(); mapView.Overlays.Add("GpsOverlay", gpsOverlay); popupOverlay = new PopupOverlay(); mapView.Overlays.Add("popupOverlay", popupOverlay); mapView.MapLongPress += mapView_MapLongPress; mapView.MapSingleTap += mapView_MapSingleTap; mapView.MapDoubleTap += mapView_MapDoubleTap; mapView.CurrentScaleChanged += mapView_CurrentScaleChanged; scaleZoomLevelMapTool = new ScaleZoomLevelMapTool(mapView, this); scaleZoomLevelMapTool.IsEnabled = true; RelativeLayout.LayoutParams scaleZoomLevelMapToolLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); scaleZoomLevelMapToolLayoutParams.AddRule(LayoutRules.AlignParentRight); scaleZoomLevelMapToolLayoutParams.AddRule(LayoutRules.AlignParentBottom); scaleZoomLevelMapTool.LayoutParameters = scaleZoomLevelMapToolLayoutParams; scaleZoomLevelMapTool.SetY(-100 * MapView.DisplayDensity); mapView.MapTools.Add(scaleZoomLevelMapTool); mapView.MapTools.CenterCoordinate.IsEnabled = true; mapView.MapTools.CenterCoordinate.SetY(-100 * MapView.DisplayDensity); } /// <summary> /// Initializes the animations for toolsBar. /// </summary> private void InitializeAnimations() { toolsBarInAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.toolsBar_in); toolsBarOutAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.toolsBar_out); toolsBarInAnimation.AnimationEnd += (sender, e) => { FrameLayout toolsBarBorderLayout = FindViewById<FrameLayout>(Resource.Id.ToolsBarBorderFrameLayout); if (toolsBarBorderLayout != null) { toolsBarBorderLayout.Visibility = ViewStates.Visible; } }; toolsBarOutAnimation.AnimationEnd += (sender, e) => { FrameLayout toolsBarBorderLayout = FindViewById<FrameLayout>(Resource.Id.ToolsBarBorderFrameLayout); if (toolsBarBorderLayout != null) { toolsBarBorderLayout.Visibility = ViewStates.Gone; } }; } /// <summary> /// Checks the GPS service is enable or not. /// </summary> private bool CheckGpsService(bool withToast = false) { bool result = locationManager.IsProviderEnabled(LocationManager.GpsProvider); if (withToast && !result) { Toast.MakeText(this, "Please Open Gps Service!", ToastLength.Long).Show(); } return result; } /// <summary> /// Checks the GPS service, if it is enable, start GPS Tracking, if not, open GPS setting dialog. /// </summary> private void CheckGpsServiceAndOpenSettings() { if (!CheckGpsService()) { OpenGpsSettingsDialog gpsSettingDialog = new OpenGpsSettingsDialog(this); gpsSettingDialog.Show(); gpsSettingDialog.CancelEvent += (sender, e) => { if (gpsSettingDialog.OpenSettings) { Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS"); StartActivityForResult(intent, 100); } }; } else { StartGpsTracking(); RefreshGpsLocation(locationManager.GetLastKnownLocation(bestGpsProvider)); } } } }
using Android.App; using Android.OS; using Android.Webkit; namespace GettingStartedSample { /// <summary> /// This class represents the info window after clicking on the info button. /// </summary> [Activity(Label|= "Help")] public class InfoActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.WebView); WebView webView = FindViewById<WebView>(Resource.Id.localWebView); webView.LoadUrl("http://thinkgeo.com/map-suite-developer-gis/android-edition/"); } } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using System; namespace GettingStartedSample { /// <summary> /// This class represents the Open GPS Settings Dialog which will be only showed up if the GPS is not enable when this app starts. /// </summary> public class OpenGpsSettingsDialog : AlertDialog { private bool openSettings; public OpenGpsSettingsDialog(Context context) : base(context) { openSettings = false; View openGpsSettingsView = View.Inflate(context, Resource.Layout.OpenGpsSettingsLayout, null); SetView(openGpsSettingsView); Button cancelButton = openGpsSettingsView.FindViewById<Button>(Resource.Id.CancelButton); Button okButton = openGpsSettingsView.FindViewById<Button>(Resource.Id.OkButton); okButton.Click += OkButtonClick; cancelButton.Click += CancelButtonClick; } public bool OpenSettings { get { return openSettings; } } private void CancelButtonClick(object sender, EventArgs e) { openSettings = false; Cancel(); } private void OkButtonClick(object sender, EventArgs e) { openSettings = true; Cancel(); } } }
using Android.Content; using Android.Util; using Android.Widget; using System; using System.Globalization; using ThinkGeo.MapSuite.AndroidEdition; namespace GettingStartedSample { /// <summary> /// This class represents the Scale/ZoomLevel we displayed on the map. /// </summary> public class ScaleZoomLevelMapTool : MapTool { private TextView contentLabel; private MapView currentMap; public ScaleZoomLevelMapTool(MapView mapView, Context context) : base(context) { Init(mapView, context, null); } public ScaleZoomLevelMapTool(MapView mapView, Context context, IAttributeSet attrs) : base(context) { Init(mapView, context, attrs); } private void Init(MapView mapView, Context context, IAttributeSet attrs) { currentMap = mapView; contentLabel = new TextView(context); contentLabel.SetTextColor(Android.Graphics.Color.Black); AddView(contentLabel); mapView.CurrentScaleChanged += MapView_CurrentScaleChanged; } private void MapView_CurrentScaleChanged(object sender, CurrentScaleChangedMapViewEventArgs e) { UpdateScaleContent(e.NewScale); } private void UpdateScaleContent(double newScale = double.NaN) { if (!double.IsNaN(newScale)) { int zoomLevelIndex = currentMap.GetSnappedZoomLevelIndex(newScale); contentLabel.Text = String.Format(CultureInfo.InvariantCulture, "Scale 1 : {0:N0}\r\nZoomLevel : {1:N0}", newScale, zoomLevelIndex); } else { contentLabel.Text = "Scale 1 : --\r\nZoomLevel : --"; } } protected override void Dispose(bool isDisposing) { if (isDisposing) { contentLabel.Dispose(); GC.SuppressFinalize(this); } } } }
using Android.App; using Android.Content; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; using ThinkGeo.MapSuite.AndroidEdition; using ThinkGeo.MapSuite.Core; namespace GettingStartedSample { /// <summary> /// This class represents the Select ZoomLevel List Dialog which would be popped up when tabbing and holding on the map. /// </summary> public class SelectZoomLevelListDialog : AlertDialog { private ZoomLevel currentZoomLevel; private MapView currentMapView; public SelectZoomLevelListDialog(Context context, MapView mapView) : base(context) { currentMapView = mapView; View selectZoomLevelView = View.Inflate(context, Resource.Layout.SelectZoomLevelLayout, null); this.SetView(selectZoomLevelView); ImageButton closeButton = selectZoomLevelView.FindViewById<ImageButton>(Resource.Id.closeButton); ListView zoomLevelList = selectZoomLevelView.FindViewById<ListView>(Resource.Id.zoomLevelListView); ZoomLevelListAdapter adapter = new ZoomLevelListAdapter(context); foreach (var item in GetData()) { adapter.Data.Add(item); } zoomLevelList.Adapter = adapter; closeButton.Click += CloseButtonClick; zoomLevelList.ItemClick += ZoomLevelListItemClick; } public override void Show() { base.Show(); int width = this.Window.WindowManager.DefaultDisplay.Width / 3; WindowManagerLayoutParams windowLayoutParams = this.Window.Attributes; windowLayoutParams.Gravity = GravityFlags.Center; windowLayoutParams.Width = width < 250 * MapView.DisplayDensity ? (int)(250 * MapView.DisplayDensity) : width; Window.Attributes = windowLayoutParams; Window.SetGravity(GravityFlags.Center); } public ZoomLevel CurrentZoomLevel { get { return currentZoomLevel; } } private void CloseButtonClick(object sender, EventArgs e) { Cancel(); } private void ZoomLevelListItemClick(object sender, AdapterView.ItemClickEventArgs e) { switch (e.Position) { case 0: currentZoomLevel = currentMapView.ZoomLevelSet.ZoomLevel02; break; case 1: currentZoomLevel = currentMapView.ZoomLevelSet.ZoomLevel05; break; case 2: currentZoomLevel = currentMapView.ZoomLevelSet.ZoomLevel10; break; case 3: currentZoomLevel = currentMapView.ZoomLevelSet.ZoomLevel16; break; case 4: currentZoomLevel = currentMapView.ZoomLevelSet.ZoomLevel18; break; } Cancel(); } private static List<Dictionary<string, object>> GetData() { List<Dictionary<string, object>> data = new List<Dictionary<string, object>>(); Dictionary<string, object> level2 = new Dictionary<string, object>(); Dictionary<string, object> level5 = new Dictionary<string, object>(); Dictionary<string, object> level10 = new Dictionary<string, object>(); Dictionary<string, object> level16 = new Dictionary<string, object>(); Dictionary<string, object> level18 = new Dictionary<string, object>(); level2.Add("ZoomLevel", "Level2:(1:295295895)"); level5.Add("ZoomLevel", "Level5:(1:36911986)"); level10.Add("ZoomLevel", "Level10:(1:1153499)"); level16.Add("ZoomLevel", "Level16:(1:180123)"); level18.Add("ZoomLevel", "Level18:(1:4505)"); data.Add(level2); data.Add(level5); data.Add(level10); data.Add(level16); data.Add(level18); return data; } /// <summary> /// This class represents the adapter used in SelectZoomLevelListDialog. /// </summary> private class ZoomLevelListAdapter : BaseAdapter { private LayoutInflater mInflater; private List<Dictionary<string, object>> data; public ZoomLevelListAdapter(Context context) { mInflater = LayoutInflater.From(context); } public List<Dictionary<string, object>> Data { get { return data ?? (data = new List<Dictionary<string, object>>()); } } 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) { ZoomLevelItemsHolder holder = null; if (convertView == null) { holder = new ZoomLevelItemsHolder(); convertView = mInflater.Inflate(Resource.Layout.ZoomLevelListTemplate, null); holder.ZoomLevelValue = convertView.FindViewById<TextView>(Resource.Id.ZoomLevelTextView); convertView.Tag = holder; } else { holder = (ZoomLevelItemsHolder)convertView.Tag; } AbsListView.LayoutParams lp = new AbsListView.LayoutParams(LinearLayout.LayoutParams.FillParent, 35); convertView.LayoutParameters = lp; holder.ZoomLevelValue.Text = data[position]["ZoomLevel"] as string; return convertView; } private class ZoomLevelItemsHolder : Java.Lang.Object { public TextView ZoomLevelValue; } } } }
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("GettingStartedSample")] [assembly: AssemblyDescription("")] [assembly:|AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly:|AssemblyProduct("GettingStartedSample")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly:|AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly:|ComVisible(false)] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly:|AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly:|AssemblyFileVersion("1.0.0.0")]
#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("GettingStartedSample.Resource", IsApplication=true)] namespace GettingStartedSample { [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::GettingStartedSample.Resource.Drawable.icon_mapsuite_default256x256; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_default512x512 = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_default512x512; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_globe; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_globe_Pressed = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_globe_Pressed; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_Minus; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Minus_Pressed = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_Minus_Pressed; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_noImageTile = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_noImageTile; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_Plus; global::ThinkGeo.MapSuite.AndroidEdition.Resource.Drawable.icon_mapsuite_Plus_Pressed = global::GettingStartedSample.Resource.Drawable.icon_mapsuite_Plus_Pressed; } public partial class Animation { // aapt resource value: 0x7f040000 public const int fade_in = 2130968576; // aapt resource value: 0x7f040001 public const int fade_out = 2130968577; // aapt resource value: 0x7f040002 public const int location_scale_big = 2130968578; // aapt resource value: 0x7f040003 public const int location_scale_small = 2130968579; // aapt resource value: 0x7f040004 public const int toolsBar_in = 2130968580; // aapt resource value: 0x7f040005 public const int toolsBar_out = 2130968581; static Animation() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Animation() { } } public partial class Attribute { static Attribute() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Attribute() { } } public partial class Drawable { // aapt resource value: 0x7f020000 public const int close = 2130837504; // aapt resource value: 0x7f020001 public const int fullext40X40 = 2130837505; // aapt resource value: 0x7f020002 public const int Icon = 2130837506; // aapt resource value: 0x7f020003 public const int icon_mapsuite_default256x256 = 2130837507; // aapt resource value: 0x7f020004 public const int icon_mapsuite_default512x512 = 2130837508; // aapt resource value: 0x7f020005 public const int icon_mapsuite_globe = 2130837509; // aapt resource value: 0x7f020006 public const int icon_mapsuite_globe_Pressed = 2130837510; // aapt resource value: 0x7f020007 public const int icon_mapsuite_Minus = 2130837511; // aapt resource value: 0x7f020008 public const int icon_mapsuite_Minus_Pressed = 2130837512; // aapt resource value: 0x7f020009 public const int icon_mapsuite_noImageTile = 2130837513; // aapt resource value: 0x7f02000a public const int icon_mapsuite_Plus = 2130837514; // aapt resource value: 0x7f02000b public const int icon_mapsuite_Plus_Pressed = 2130837515; // aapt resource value: 0x7f02000c public const int info40X40 = 2130837516; // aapt resource value: 0x7f02000d public const int location40X40 = 2130837517; // aapt resource value: 0x7f02000e public const int MapSuite = 2130837518; // aapt resource value: 0x7f02000f public const int More = 2130837519; // aapt resource value: 0x7f020010 public const int Nxtext40X40 = 2130837520; // aapt resource value: 0x7f020011 public const int portrait = 2130837521; // aapt resource value: 0x7f020012 public const int Preext40X40 = 2130837522; static Drawable() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Drawable() { } } public partial class Id { // aapt resource value: 0x7f07000f public const int CancelButton = 2131165199; // aapt resource value: 0x7f07000e public const int OkButton = 2131165198; // aapt resource value: 0x7f070008 public const int ToolButtonsLayout = 2131165192; // aapt resource value: 0x7f070006 public const int ToolsBarBorderFrameLayout = 2131165190; // aapt resource value: 0x7f070002 public const int ToolsBarHeaderLayout = 2131165186; // aapt resource value: 0x7f070001 public const int ToolsBarLinearLayout = 2131165185; // aapt resource value: 0x7f070013 public const int ZoomLevelTextView = 2131165203; // aapt resource value: 0x7f070000 public const int androidMap = 2131165184; // aapt resource value: 0x7f070010 public const int closeButton = 2131165200; // aapt resource value: 0x7f070004 public const int frameLayout1 = 2131165188; // aapt resource value: 0x7f07000a public const int fullextImageButton = 2131165194; // aapt resource value: 0x7f07000d public const int infoImageButton = 2131165197; // aapt resource value: 0x7f070007 public const int landscapeTextView = 2131165191; // aapt resource value: 0x7f070012 public const int localWebView = 2131165202; // aapt resource value: 0x7f070009 public const int locationImageButton = 2131165193; // aapt resource value: 0x7f070005 public const int moreImage = 2131165189; // aapt resource value: 0x7f07000c public const int nxtextImageButton = 2131165196; // aapt resource value: 0x7f07000b public const int preextImageButton = 2131165195; // aapt resource value: 0x7f070003 public const int textView1 = 2131165187; // aapt resource value: 0x7f070011 public const int zoomLevelListView = 2131165201; static Id() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Id() { } } public partial class Layout { // aapt resource value: 0x7f030000 public const int ButtonBackgroundSelector = 2130903040; // aapt resource value: 0x7f030001 public const int Main = 2130903041; // aapt resource value: 0x7f030002 public const int OpenGpsSettingsLayout = 2130903042; // aapt resource value: 0x7f030003 public const int SelectZoomLevelLayout = 2130903043; // aapt resource value: 0x7f030004 public const int ToolsBarTitleBackground = 2130903044; // aapt resource value: 0x7f030005 public const int WebView = 2130903045; // aapt resource value: 0x7f030006 public const int ZoomLevelListTemplate = 2130903046; static Layout() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Layout() { } } public partial class String { // aapt resource value: 0x7f050001 public const int ApplicationName = 2131034113; // aapt resource value: 0x7f050000 public const int Hello = 2131034112; static String() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private String() { } } public partial class Style { // aapt resource value: 0x7f060000 public const int Theme_Splash = 2131099648; static Style() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); } private Style() { } } } } #pragma warning restore 1591