Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ShapeFileFeatureLayer txwatFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXwat.shp"));

            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(255, 153, 179, 204);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("LandName", "Arial", 9, DrawingFontStyles.Italic, GeoColor.StandardColors.Navy);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle.SuppressPartialLabels = true;
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer txlkaA40FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA40.shp"));

            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel14.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            txlkaA40FeatureLayer.DrawingMarginPercentage = 80;

            ShapeFileFeatureLayer txlkaA20FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA20.shp"));

            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 6, GeoColor.StandardColors.LightGray, 9, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 9, GeoColor.StandardColors.LightGray, 12, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay();

            Marker thinkGeoMarker = new Marker(BaseContext);

            thinkGeoMarker.Position = new PointShape(-96.809523, 33.128675);
            thinkGeoMarker.YOffset  = -(int)(22 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
            thinkGeoMarker.SetImageBitmap(BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin));
            thinkGeoMarker.Click += ThinkGeoMarkerClick;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(txlkaA40FeatureLayer);
            layerOverlay.Layers.Add(txwatFeatureLayer);
            layerOverlay.Layers.Add(txlkaA20FeatureLayer);

            MarkerOverlay markerOverlay = new MarkerOverlay();

            markerOverlay.Markers.Add(thinkGeoMarker);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-96.8172, 33.1299, -96.8050, 33.1226);
            androidMap.Overlays.Add(worldMapKitOverlay);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.Overlays.Add(markerOverlay);
            androidMap.Overlays.Add("PopupOverlay", new PopupOverlay());

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
        private void GetDistanceButtonClick(object sender, EventArgs e)
        {
            MarkerOverlay markerOverlayr = androidMap.Overlays["Marker"] as MarkerOverlay;
            Marker        usMarker       = markerOverlayr.Markers[0];
            Marker        chinaMarker    = markerOverlayr.Markers[1];
            double        distance       = usMarker.Position.GetDistanceTo(chinaMarker.Position, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer);

            distanceTextView.Text = string.Format("{0:N4} Km", distance);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/Countries02.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Marker usMarker = new Marker(this);

            usMarker.Position = new PointShape(-98.58, 39.57);
            usMarker.YOffset  = -22;
            usMarker.SetImageBitmap(Android.Graphics.BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin));

            Marker chinaMarker = new Marker(this);

            chinaMarker.Position = new PointShape(104.72, 34.45);
            chinaMarker.YOffset  = -22;
            chinaMarker.SetImageBitmap(Android.Graphics.BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin));

            MarkerOverlay markerOverlay = new MarkerOverlay();

            markerOverlay.Markers.Add(usMarker);
            markerOverlay.Markers.Add(chinaMarker);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(worldLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.Overlays.Add("Marker", markerOverlay);

            Button getDistanceButton = new Button(this);

            getDistanceButton.Click           += GetDistanceButtonClick;
            getDistanceButton.Text             = "Get Distance";
            getDistanceButton.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            distanceTextView = new TextView(this);

            LinearLayout linearLayout = new LinearLayout(this);

            linearLayout.Orientation = Orientation.Horizontal;
            linearLayout.AddView(getDistanceButton);
            linearLayout.AddView(distanceTextView);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType(), new Collection <View>()
            {
                linearLayout
            });
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ShapeFileFeatureLayer txwatFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXwat.shp"));

            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(255, 153, 179, 204);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("LandName", "Arial", 9, DrawingFontStyles.Italic, GeoColor.StandardColors.Navy);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle.SuppressPartialLabels = true;
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer txlkaA40FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA40.shp"));

            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel14.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            txlkaA40FeatureLayer.DrawingMarginPercentage = 80;

            ShapeFileFeatureLayer txlkaA20FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA20.shp"));

            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 6, GeoColor.StandardColors.LightGray, 9, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 9, GeoColor.StandardColors.LightGray, 12, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            markerOverlay = new MarkerOverlay();
            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add("TXwat", txwatFeatureLayer);
            layerOverlay.Layers.Add("TXlkaA20", txlkaA20FeatureLayer);
            layerOverlay.Layers.Add("TXlkaA40", txlkaA40FeatureLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-96.8172, 33.1299, -96.8050, 33.1226);
            androidMap.Overlays.Add("markerOverlay", markerOverlay);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.MapSingleTap += AndroidMap_MapSingleTap;

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Exemplo n.º 5
0
        public override void Display()
        {
            MapOverlay overlay = null;

            if (Point != null)
            {
                uint layer;

                if (isStatic)
                {
                    layer = (uint)OverlayLayers.Static_Points;
                }
                //else if (ObjectType == "MVMD" || ObjectType == "MPDGD" || ObjectType == "MPDGF")
                //    layer = (uint)OverlayLayers.Markers;
                else
                {
                    layer = (uint)OverlayLayers.Pilot_Points;
                }
                //else
                //    layer = (uint)OverlayLayers.Reference_Points;

                switch (Definition.DisplayMode)
                {
                case "NONE":
                    break;

                case "":
                case "WAYPOINT":
                {
                    overlay = new WaypointOverlay(Point.ToWindowsPoint(), Definition.ObjectName)
                    {
                        Layer = layer, Color = this.Color
                    };
                }
                break;

                case "TARGET":
                {
                    overlay = new TargetOverlay(Point.ToWindowsPoint(), radius, Definition.ObjectName)
                    {
                        Layer = layer, Color = this.Color
                    };
                }
                break;

                case "MARKER":
                {
                    overlay = new MarkerOverlay(Point.ToWindowsPoint(), Definition.ObjectName)
                    {
                        Layer = layer, Color = this.Color
                    };
                } break;

                case "CROSSHAIRS":
                {
                    overlay = new CrosshairsOverlay(Point.ToWindowsPoint())
                    {
                        Layer = layer, Color = this.Color
                    };
                }
                break;
                }
            }

            if (overlay != null)
            {
                Engine.MapViewer.AddOverlay(overlay);
            }
        }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ShapeFileFeatureLayer txwatFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXwat.shp"));

            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(255, 153, 179, 204);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("LandName", "Arial", 9, DrawingFontStyles.Italic, GeoColor.StandardColors.Navy);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle.SuppressPartialLabels = true;
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer txlkaA40FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA40.shp"));

            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel14.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            txlkaA40FeatureLayer.DrawingMarginPercentage = 80;

            ShapeFileFeatureLayer txlkaA20FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA20.shp"));

            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 6, GeoColor.StandardColors.LightGray, 9, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 9, GeoColor.StandardColors.LightGray, 12, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Marker thinkGeoMarker = new Marker(BaseContext);

            thinkGeoMarker.Position = new PointShape(-96.809523, 33.128675);
            thinkGeoMarker.SetImageBitmap(Android.Graphics.BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin));
            thinkGeoMarker.YOffset = -(int)(22 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);

            MarkerOverlay markerOverlay = new MarkerOverlay();

            markerOverlay.Markers.Add(thinkGeoMarker);

            ImageView imageView = new ImageView(this);

            imageView.SetImageResource(Resource.Drawable.ThinkGeoLogo);

            TextView textView = new TextView(this);

            textView.Text = string.Format("Longitude : {0:N4}" + "\r\n" + "Latitude : {1:N4}", thinkGeoMarker.Position.X, thinkGeoMarker.Position.Y);
            textView.SetTextColor(Color.Black);
            textView.SetTextSize(ComplexUnitType.Px, 22);

            LinearLayout linearLayout = new LinearLayout(this);

            linearLayout.SetPadding(10, 10, 10, 10);
            linearLayout.Orientation = Orientation.Vertical;
            linearLayout.AddView(imageView);
            linearLayout.AddView(textView);

            Popup popup = new Popup(this);

            popup.Position = thinkGeoMarker.Position;
            popup.YOffset  = (int)(-44 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
            popup.XOffset  = (int)(4 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
            popup.AddView(linearLayout);

            PopupOverlay popupOverlay = new PopupOverlay();

            popupOverlay.Popups.Add(popup);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(txwatFeatureLayer);
            layerOverlay.Layers.Add(txlkaA20FeatureLayer);
            layerOverlay.Layers.Add(txlkaA40FeatureLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-96.8172, 33.1299, -96.8050, 33.1226);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.Overlays.Add(markerOverlay);
            androidMap.Overlays.Add(popupOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Exemplo n.º 7
0
        private void InitMap()
        {
            //add a map grid
            map.AddOverlay(new CoordinateGridOverlay(1000));

            // add a random track
            var rnd      = new Random();
            var position = new Point(302263, 4609451);
            var trackLog = new Point[6000];
            var utm      = new Point(position.X, position.Y);

            trackLog[0] = position;

            double amplitude = Math.PI / 10, stroke = 10;
            double ang = 0, dist;

            for (var i = 1; i < trackLog.Length; i++)
            {
                ang        += amplitude * (rnd.NextDouble() - 0.5);
                dist        = stroke * (1 + rnd.NextDouble()) / 2;
                utm.X      += dist * Math.Cos(ang);
                utm.Y      += dist * Math.Sin(ang);
                trackLog[i] = new Point(utm.X, utm.Y);
            }
            var track = new TrackOverlay(trackLog, 2);

            track.Color = Colors.Blue;
            map.AddOverlay(track);

            //add crosshairs
            position = trackLog[rnd.Next(trackLog.Length)];
            var crosshairs = new CrosshairsOverlay(position);

            crosshairs.Color = Colors.Red;
            map.AddOverlay(crosshairs);

            //add a marker
            position = trackLog[rnd.Next(trackLog.Length)];
            var marker = new MarkerOverlay(position, "Marker 1");

            marker.Color = Colors.Green;
            map.AddOverlay(marker);

            //add a target
            position = new Point(306000, 4609000);
            var target = new TargetOverlay(position, 100, "Target 1");

            target.Color = Colors.Yellow;
            map.AddOverlay(target);

            //add a waypoint
            position = new Point(305500, 4608500);
            var waypoint = new WaypointOverlay(position, "Waypoint 1");

            waypoint.Color = Colors.Orange;
            map.AddOverlay(waypoint);

            //add a poligonal area
            var polygon = new Point[] {
                new Point(303000, 4610000),
                new Point(305000, 4610000),
                new Point(305000, 4612000),
                new Point(303000, 4612000)
            };
            var area = new PolygonalAreaOverlay(polygon, "AREA 1");

            area.Color = Colors.Orange;
            map.AddOverlay(area);

            //add a PZ
            position = new Point(308000, 4608000);
            var pz = new CircularAreaOverlay(position, 500, "BPZ1");

            pz.Color = Colors.Blue;
            map.AddOverlay(pz);

            {
                //add a distance
                var d        = Math.Sqrt(Math.Pow(marker.Position.X - target.Position.X, 2) + Math.Pow(marker.Position.Y - target.Position.Y, 2));
                var distance = new DistanceOverlay(target.Position, marker.Position, "Distance D" + Environment.NewLine + d.ToString("0m"));
                map.AddOverlay(distance);
            }

            {
                //add an angle
                var a     = Angle(track.Position, crosshairs.Position, trackLog[trackLog.Length - 1]);
                var angle = new AngleOverlay(track.Position, crosshairs.Position, trackLog[trackLog.Length - 1], "Angle alpha" + Environment.NewLine + a.ToString("0.00°"));
                map.AddOverlay(angle);
            }
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayMapView);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/Countries02.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Marker thinkGeoMarker = new Marker(this);

            thinkGeoMarker.Position = new PointShape(-95.2806, 38.9554);
            thinkGeoMarker.YOffset  = -22;
            thinkGeoMarker.SetImageBitmap(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.Pin));

            MarkerOverlay markerOverlay = new MarkerOverlay();

            markerOverlay.Markers.Add(thinkGeoMarker);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(worldLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.Overlays.Add(markerOverlay);

            Button convertButton = new Button(this);

            convertButton.Click           += ConvertButtonClick;
            convertButton.Text             = "Convert";
            convertButton.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);

            longitudeTextView      = new EditText(this);
            longitudeTextView.Text = "-95.2806";
            latitudeTextView       = new EditText(this);
            latitudeTextView.Text  = "38.9554";

            resultView = new TextView(this);

            LinearLayout verticalLinearLayout = new LinearLayout(this);

            verticalLinearLayout.Orientation = Orientation.Vertical;
            verticalLinearLayout.AddView(longitudeTextView);
            verticalLinearLayout.AddView(latitudeTextView);

            LinearLayout horizontalLinearLayout = new LinearLayout(this);

            horizontalLinearLayout.Orientation = Orientation.Horizontal;
            horizontalLinearLayout.AddView(verticalLinearLayout);
            horizontalLinearLayout.AddView(convertButton);
            horizontalLinearLayout.AddView(resultView);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType(), new Collection <View>()
            {
                horizontalLinearLayout
            });
        }