コード例 #1
0
        protected override NativePolygon CreateNativeItem(Polygon outerItem)
        {
            var opts = new PolygonOptions();

            foreach (var p in outerItem.Positions)
            {
                opts.Add(new LatLng(p.Latitude, p.Longitude));
            }

            opts.InvokeStrokeWidth(outerItem.StrokeWidth * this.ScaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
            opts.InvokeStrokeColor(outerItem.StrokeColor.ToAndroid());
            opts.InvokeFillColor(outerItem.FillColor.ToAndroid());
            opts.Clickable(outerItem.IsClickable);

            var nativePolygon = NativeMap.AddPolygon(opts);

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = nativePolygon;
            outerItem.SetOnPositionsChanged((polygon, e) =>
            {
                var native    = polygon.NativeObject as NativePolygon;
                native.Points = polygon.Positions.ToLatLngs();
            });

            return(nativePolygon);
        }
コード例 #2
0
        private void HandleInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
        {
            // Draw a circle on the map
            CircleOptions circleOptions = new CircleOptions();

            circleOptions.InvokeCenter(Location_NewYork);
            circleOptions.InvokeRadius(100000.0);
            circleOptions.InvokeFillColor(Android.Graphics.Color.White);
            _map.AddCircle(circleOptions);

            // Draw a polygon (Wyoming) on the map
            PolygonOptions polygonOptions = new PolygonOptions();

            polygonOptions.Add(new LatLng[]
            {
                new LatLng(45.00, -111.00),
                new LatLng(45, -104),
                new LatLng(41, -104),
                new LatLng(41, -111)
            });

            polygonOptions.InvokeFillColor(Android.Graphics.Color.Purple);
            polygonOptions.InvokeStrokeWidth(2);
            _map.AddPolygon(polygonOptions);
        }
コード例 #3
0
 protected override void OnMapReady(GoogleMap map)
 {
     base.OnMapReady(map);
     GoogleMap = map;
     map.UiSettings.MapToolbarEnabled = false;
     if (FormsMap.RoutePins != null && FormsMap.RoutePins.Count > 1)
     {
         var polylineOptions = new PolylineOptions();
         polylineOptions.InvokeColor(Color.Red.ToAndroid());
         foreach (var pins in FormsMap.RoutePins)
         {
             polylineOptions.Add(new LatLng(pins.Position.Latitude, pins.Position.Longitude));
         }
         NativeMap.AddPolyline(polylineOptions);
     }
     else if (FormsMap.AvailableRegions != null)
     {
         var polygonOptions = new PolygonOptions();
         polygonOptions.InvokeFillColor(Android.Graphics.Color.ParseColor("#2271cce7"));
         polygonOptions.InvokeStrokeColor(Android.Graphics.Color.ParseColor("#2271cce7"));
         polygonOptions.InvokeStrokeWidth(15.0f);
         foreach (var position in FormsMap.AvailableRegions)
         {
             polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
         }
         NativeMap.AddPolygon(polygonOptions);
     }
 }
コード例 #4
0
        void AddPolygons(IList polygons)
        {
            var map = NativeMap;

            if (map == null)
            {
                return;
            }

            if (_polygons == null)
            {
                _polygons = new List <APolygon> ();
            }

            _polygons.AddRange(polygons.Cast <Polygon> ().Select(polygon => {
                var opts = new PolygonOptions();

                foreach (var p in polygon.Positions)
                {
                    opts.Add(new LatLng(p.Latitude, p.Longitude));
                }

                opts.InvokeStrokeWidth(polygon.StrokeWidth * _scaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
                opts.InvokeStrokeColor(polygon.StrokeColor.ToAndroid());
                opts.InvokeFillColor(polygon.FillColor.ToAndroid());
                opts.Clickable(polygon.IsClickable);

                var nativePolygon = map.AddPolygon(opts);

                // associate pin with marker for later lookup in event handlers
                polygon.Id = nativePolygon;
                return(nativePolygon);
            }));
        }
コード例 #5
0
        /// <summary>
        /// Replaces the already visible zone or creates a new one.
        /// </summary>
        /// <param name="z">The z coordinate.</param>
        /// <param name="replace">The z coordinate.</param>
        void CreateZone(Zone z, Polygon replace = null)
        {
            IList <LatLng> points = new List <LatLng>(z.Points.Count);

            if (replace != null)
            {
                // Replace the points from the old polygon
                foreach (var zp in z.Points)
                {
                    points.Add(new LatLng(zp.Latitude, zp.Longitude));
                    replace.Points = points;
                }
            }
            else
            {
                // Create a new polygon for zone
                PolygonOptions po = new PolygonOptions();
                foreach (var zp in z.Points)
                {
                    po.Points.Add(new LatLng(zp.Latitude, zp.Longitude));
                }
                po.InvokeStrokeColor(Color.Argb(160, 255, 0, 0));
                po.InvokeStrokeWidth(2);
                po.InvokeFillColor(Color.Argb(80, 255, 0, 0));
                po.InvokeZIndex(1);

                // Add polygon to list of active zones
                zones.Add(z.ObjIndex, _map.AddPolygon(po));
            }
        }
コード例 #6
0
        private void SetupOverlays()
        {
            // render a circle on the map
            CircleOptions circleOptions = new CircleOptions();

            circleOptions.InvokeCenter(AtlantaCoords);
            circleOptions.InvokeRadius(8000.0);
            circleOptions.InvokeFillColor(Android.Graphics.Color.Orange);
            _map.AddCircle(circleOptions);

            // render a polygon on the map
            PolygonOptions polygonOptions = new PolygonOptions();

            polygonOptions.Add(new LatLng[]
            {
                new LatLng(25.25, -80.27),
                new LatLng(32.14, -64.97),
                new LatLng(18.23, -66.56)
            });

            polygonOptions.InvokeFillColor(Android.Graphics.Color.Yellow);
            polygonOptions.InvokeStrokeWidth(8);
            _map.AddPolygon(polygonOptions);

            // overlay images at physical size: _map.AddGroundOverlay
        }
コード例 #7
0
        protected virtual PolygonOptions CreatePolygonOptions(Polygon polygon)
        {
            var opts = new PolygonOptions();

            opts.InvokeStrokeColor(polygon.StrokeColor.ToAndroid(Color.Black));
            opts.InvokeStrokeWidth(polygon.StrokeWidth);

            if (!polygon.StrokeColor.IsDefault)
            {
                opts.InvokeFillColor(polygon.FillColor.ToAndroid());
            }

            // Will throw an exception when added to the map if Points is empty
            if (polygon.Geopath.Count == 0)
            {
                opts.Points.Add(new LatLng(0, 0));
            }
            else
            {
                foreach (var position in polygon.Geopath)
                {
                    opts.Points.Add(new LatLng(position.Latitude, position.Longitude));
                }
            }

            return(opts);
        }
コード例 #8
0
        private void OnGoogleMapReady()
        {
            var element = (ExtendedMap)Element;

            NativeMap.SetOnInfoWindowClickListener(this);

            if (element.ItemsSource != null)
            {
                LoadPins(element);
            }

            if (element.Coverages != null)
            {
                foreach (Logic.Models.Domain.Polygon coverage in Coverages)
                {
                    int            inCB    = 0x66129EE0;
                    int            outCB   = 0x6601456B;
                    PolygonOptions polygon = new PolygonOptions();
                    if (coverage.CoverageCode == "CB")
                    {
                        polygon.InvokeFillColor(inCB);
                    }
                    else
                    {
                        polygon.InvokeFillColor(outCB);
                    }
                    polygon.InvokeStrokeColor(0x660000FF);
                    polygon.InvokeStrokeWidth(1);

                    if (coverage.Points != null)
                    {
                        bool Point = false;
                        foreach (Logic.Models.Domain.Point position in coverage.Points)
                        {
                            polygon.Add(new LatLng(position.Latitude, position.Longitude));
                            Point = true;
                        }
                        if (Point)
                        {
                            NativeMap.AddPolygon(polygon);
                        }
                    }
                }
            }

            isDrawn = true;
        }
コード例 #9
0
        private PolygonOptions GetPolygon()
        {
            PolygonOptions polygon = new PolygonOptions();

            polygon.InvokeFillColor(0x66FF0000);
            polygon.InvokeStrokeColor(0x660000FF);
            polygon.InvokeStrokeWidth(10.0f);
            return(polygon);
        }
コード例 #10
0
        private static PolygonOptions GetPolygoneRenderer()
        {
            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(0x66FF0000);
            polygonOptions.InvokeStrokeColor(0x66FF0000);
            polygonOptions.InvokeStrokeWidth(10.0f);
            return(polygonOptions);
        }
コード例 #11
0
        private PolygonOptions GetPolygonOptions()
        {
            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeStrokeColor(Android.Graphics.Color.Orange);
            polygonOptions.InvokeFillColor(Android.Graphics.Color.GreenYellow);
            polygonOptions.InvokeStrokeWidth(3);
            polygonOptions.Clickable(true);
            return(polygonOptions);
        }
コード例 #12
0
 private void SetColor(Color color)
 {
     try
     {
         if (CellPolygon != null)
         {
             CellPolygon.FillColor = color;
             cellPolygonOptions.InvokeFillColor(color);
         }
         else
         {
             cellPolygonOptions.InvokeFillColor(color);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
コード例 #13
0
        /// <summary>
        /// Gets the polygon.
        /// </summary>
        /// <returns>The polygon.</returns>
        /// <param name="coordinates">Cordinates iterable.</param>
        /// <param name="fillColor">Fill color.</param>
        /// <param name="boundaryColor">Boundary color.</param>
        private static PolygonOptions GetPolygon(Java.Lang.IIterable coordinates, Android.Graphics.Color fillColor, Android.Graphics.Color boundaryColor)
        {
            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(fillColor);
            polygonOptions.InvokeStrokeWidth(4);
            polygonOptions.InvokeStrokeColor(boundaryColor);
            polygonOptions.AddAll(coordinates);

            return(polygonOptions);
        }
コード例 #14
0
        /// <summary>
        /// Gets the polygon.
        /// </summary>
        /// <returns>The polygon.</returns>
        /// <param name="coordinates">Coordinates iterable.</param>
        /// <param name="color">Android Color.</param>
        private static PolygonOptions GetPolygon(Java.Lang.IIterable coordinates, Android.Graphics.Color color)
        {
            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(color);
            polygonOptions.InvokeStrokeWidth(1);
            polygonOptions.InvokeStrokeColor(Color.Black.ToAndroid());
            polygonOptions.AddAll(coordinates);

            return(polygonOptions);
        }
コード例 #15
0
        private void drawPolygone()
        {
            Polygon        polygon1;
            PolygonOptions polygon1Options = new PolygonOptions()
                                             .Add(new LatLng(41.01929, 28.967267), new LatLng(41.016785, 28.986971), new LatLng(41.014623, 28.999753), new LatLng(41.001917, 28.978743), new LatLng(41.002298, 28.954132));

            polygon1Options.InvokeFillColor(Color.Argb(60, 255, 200, 0));
            polygon1Options.InvokeStrokeColor(Color.Green);
            polygon1Options.InvokeStrokeWidth(30);
            polygon1Options.Clickable(true);
            polygon1Options.InvokeZIndex(2);
            polygon1 = hMap.AddPolygon(polygon1Options);
        }
コード例 #16
0
        public MapOverlay(Cell cell)
        {
            CellID = cell.ID;

            PolygonOptions = new PolygonOptions();
            PolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude)); //first rectangle point
            PolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude + (double)GameModel.FrontierInterval));
            PolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude + (double)GameModel.FrontierInterval));
            PolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude)); //automatically connects last two points

            Color color = ColorCode.TeamColor(cell.TeamID);

            PolygonOptions.InvokeFillColor(color); //Transparent (alpha) int [0-255] 255 being opaque
            PolygonOptions.InvokeStrokeWidth(0);
        }
コード例 #17
0
        //add polygon shape to map
        public void addShape()
        {
            PolygonOptions polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(0x66D0D0FF); //D0D0FF //00C8FF
            polygonOptions.InvokeStrokeColor(0x660000FF);
            polygonOptions.InvokeStrokeWidth(10.0f);

            foreach (var position in shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }
            polygon = NativeMap.AddPolygon(polygonOptions);
            NativeMap.MapLongClick += longClick;
        }
コード例 #18
0
        protected override void OnMapReady(Android.Gms.Maps.GoogleMap map)
        {
            base.OnMapReady(map);

            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(0x66FF0000);
            polygonOptions.InvokeStrokeColor(0x660000FF);
            polygonOptions.InvokeStrokeWidth(30.0f);

            foreach (var position in shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }
            NativeMap.AddPolygon(polygonOptions);
        }
コード例 #19
0
        public void OnMapReady(GoogleMap googleMap)
        {
            map = googleMap;

            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(0x66FF0000);
            polygonOptions.InvokeStrokeColor(0x660000FF);
            polygonOptions.InvokeStrokeWidth(30.0f);

            foreach (var position in shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }

            map.AddPolygon(polygonOptions);
        }
コード例 #20
0
        protected override void DrawSearchAreaPolygon(Geoposition[] polygonData)
        {
            Color color = FormsMap.SearchPolygonColor.ToAndroid();

            var polygonOptions = new PolygonOptions();

            polygonOptions.InvokeFillColor(color);
            polygonOptions.InvokeStrokeColor(color);
            polygonOptions.InvokeStrokeWidth(1.0f);

            foreach (var position in polygonData)
            {
                var nativeCoordinate = CoordinateConverter.ConvertToNative(position);
                polygonOptions.Add(nativeCoordinate);
            }

            _currentSearchPolygon = _nativeMap.AddPolygon(polygonOptions);
        }
コード例 #21
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                var polygonOptions = new PolygonOptions();
                polygonOptions.InvokeFillColor(0x66FF0000);
                polygonOptions.InvokeStrokeColor(0x660000FF);
                polygonOptions.InvokeStrokeWidth(30.0f);

                foreach (var position in shapeCoordinates)
                {
                    polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }
                NativeMap.AddPolygon(polygonOptions);
                isDrawn = true;
            }
        }
コード例 #22
0
        protected override NativePolygon CreateNativeItem(Polygon outerItem)
        {
            var opts = new PolygonOptions();

            foreach (var p in outerItem.Positions)
            {
                opts.Add(new LatLng(p.Latitude, p.Longitude));
            }

            opts.InvokeStrokeWidth(outerItem.StrokeWidth * this.ScaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
            opts.InvokeStrokeColor(outerItem.StrokeColor.ToAndroid());
            opts.InvokeFillColor(outerItem.FillColor.ToAndroid());
            opts.Clickable(outerItem.IsClickable);
            opts.InvokeZIndex(outerItem.ZIndex);

            foreach (var hole in outerItem.Holes)
            {
                opts.Holes.Add(hole.Select(x => x.ToLatLng()).ToJavaList());
            }

            var nativePolygon = NativeMap.AddPolygon(opts);

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = nativePolygon;
            outerItem.SetOnPositionsChanged((polygon, e) =>
            {
                var native    = polygon.NativeObject as NativePolygon;
                native.Points = polygon.Positions.ToLatLngs();
            });

            // FIXME workarround for #280
            //outerItem.SetOnHolesChanged((polygon, e) =>
            //{
            //    var native = polygon.NativeObject as NativePolygon;
            //    native.Holes = (IList<IList<LatLng>>)polygon.Holes
            //        .Select(x => (IList<LatLng>)x.Select(y=>y.ToLatLng()).ToJavaList())
            //        .ToJavaList();
            //});

            return(nativePolygon);
        }
コード例 #23
0
        /// <summary>
        /// Adds a polygon to the map
        /// </summary>
        /// <param name="polygon">The polygon to add</param>
        private void AddPolygon(TKPolygon polygon)
        {
            polygon.PropertyChanged += OnPolygonPropertyChanged;

            var polygonOptions = new PolygonOptions();

            if (polygon.Coordinates != null && polygon.Coordinates.Any())
            {
                polygonOptions.Add(polygon.Coordinates.Select(i => i.ToLatLng()).ToArray());
            }
            if (polygon.Color != Color.Default)
            {
                polygonOptions.InvokeFillColor(polygon.Color.ToAndroid().ToArgb());
            }
            if (polygon.StrokeColor != Color.Default)
            {
                polygonOptions.InvokeStrokeColor(polygon.StrokeColor.ToAndroid().ToArgb());
            }
            polygonOptions.InvokeStrokeWidth(polygonOptions.StrokeWidth);

            this._polygons.Add(polygon, this._googleMap.AddPolygon(polygonOptions));
        }
コード例 #24
0
        public void AddPolygon(View view)
        {
            if (null == hMap)
            {
                return;
            }
            if (null != mPolygon)
            {
                mPolygon.Remove();
            }

            PolygonOptions polygonOptions  = new PolygonOptions();
            var            rectangleLatLng = MapUtils.CreateRectangle(new LatLng(48.893478, 2.334595), 0.1, 0.1);

            foreach (LatLng item in rectangleLatLng)
            {
                polygonOptions.Add(item);
            }
            polygonOptions.InvokeFillColor(Color.Green).InvokeStrokeColor(Color.Black);
            mPolygon = hMap.AddPolygon(polygonOptions);
            hMap.SetOnPolygonClickListener(this);
        }
コード例 #25
0
        protected override void OnMapReady(GoogleMap map)
        {
            base.OnMapReady(map);

            foreach (var worksite in worksites)
            {
                var polygonOptions = new PolygonOptions();
                polygonOptions.InvokeFillColor(unchecked ((int)0xFF00FFFF));
                polygonOptions.InvokeStrokeColor(unchecked ((int)0xFF0000FF));
                polygonOptions.InvokeStrokeWidth(10.0f);

                foreach (var position in worksite.GeneratePolygonPositions())
                {
                    polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                if (polygonOptions.Points.Count > 0)
                {
                    var worksitePoly = new WorksitePolygon {
                        Worksite = worksite, Polygon = polygonOptions
                    };
                    polygons.Add(worksitePoly);
                    var polygon = NativeMap.AddPolygon(worksitePoly.Polygon);
                    polygon.Clickable = true;
                }
            }

            map.PolygonClick += (sender, e) => {
                var poly           = e.Polygon;
                var targetWorksite = polygons.FirstOrDefault(x => x.Polygon.PointsId() == poly.PointsId());

                if (targetWorksite != null)
                {
                    App.WorksiteLabel.Text      = targetWorksite.Worksite.name;
                    App.WorksiteLabel.IsVisible = true;
                }
            };
        }
コード例 #26
0
        private void OnUpdateHighlight()
        {
            var highlightableMap = (HighlightableMap)Element;

            if (highlightableMap == null || NativeMap == null)
            {
                return;
            }

            NativeMap.Clear();

            if (highlightableMap?.Highlight == null)
            {
                return;
            }

            var fillColor       = highlightableMap.Highlight.FillColor.ToAndroid().ToArgb();
            var strokeColor     = highlightableMap.Highlight.StrokeColor.ToAndroid().ToArgb();
            var strokeThickness = highlightableMap.Highlight.StrokeThickness;

            foreach (var polygon in highlightableMap.Highlight.Polygons)
            {
                var polygonOptions = new PolygonOptions();

                polygonOptions.InvokeFillColor(fillColor);
                polygonOptions.InvokeStrokeColor(strokeColor);
                polygonOptions.InvokeStrokeWidth(strokeThickness);

                foreach (var position in polygon.Positions)
                {
                    polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                NativeMap.AddPolygon(polygonOptions);
            }
        }
コード例 #27
0
        private void PolygonDemo(HuaweiMap hMap)
        {
            hMap.Clear();

            Polygon        polygon1;
            PolygonOptions polygon1Options = new PolygonOptions()
                                             .Add(new LatLng(41.01929, 28.967267), new LatLng(41.016785, 28.986971), new LatLng(41.014623, 28.999753), new LatLng(41.001917, 28.978743), new LatLng(41.002298, 28.954132));

            polygon1Options.InvokeFillColor(Color.Argb(60, 255, 200, 0));
            polygon1Options.InvokeStrokeColor(Color.Yellow);
            polygon1Options.InvokeStrokeWidth(30);
            polygon1Options.Clickable(true);
            polygon1Options.InvokeZIndex(2);
            polygon1 = hMap.AddPolygon(polygon1Options);

            Polygon        polygon2;
            PolygonOptions polygon2Options = new PolygonOptions()
                                             .Add(new LatLng(41.035243, 29.026812), new LatLng(41.022122, 29.00653), new LatLng(41.00415, 29.012449), new LatLng(41.001699, 28.978743), new LatLng(41.017384, 28.986827), new LatLng(41.037711, 28.996791));

            polygon2Options.InvokeFillColor(Color.Argb(60, 0, 0, 255));
            polygon2Options.InvokeStrokeColor(Color.Blue);
            polygon2Options.Clickable(true);
            polygon2 = hMap.AddPolygon(polygon2Options);
        }
コード例 #28
0
        public void OnMapReady(GoogleMap googleMap)
        {
            JMCdrone
            .SetPosition(latLongJMCdrone)
            .SetTitle("YMFCdrone")
            .SetSnippet(latLongJMCdrone.ToString())
            .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.JMCdroneIcon));

            if (addWayPointCounter == 0 || number_used_sats == 0)
            {
                googleMap.Clear();
                googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(latLongJMCdrone, 0));
                jmcMarker = googleMap.AddMarker(JMCdrone);
            }

            if (floatingButton2_clicked && addWayPointCounter < wayPointArray.Length - 1)
            {
                floatingButton2_clicked = false;
                if (number_used_sats <= minSats)
                {
                    addWayPointCounter = 0;
                    googleMap.Clear();
                    jmcMarker = googleMap.AddMarker(JMCdrone);
                    floatingButton2_clicked_counter = 0;
                    Toast.MakeText(this, "not enough satelities", ToastLength.Long).Show();
                }
                else
                {
                    googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(latLongJMCdrone, zoom));

                    if (floatingButton2_clicked_counter == 1)
                    {
                        addWayPointCounter++;

                        MarkerOptions newMarker = new MarkerOptions()
                                                  .SetPosition(latLongJMCdrone)
                                                  .SetSnippet(latLongJMCdrone.ToString())
                                                  .SetTitle("wp_" + addWayPointCounter.ToString())
                                                  .Draggable(true)
                                                  .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));


                        googleMap.AddMarker(newMarker).ShowInfoWindow();
                        wayPointArray[addWayPointCounter] = latLongJMCdrone;
                    }
                }
            }
            if (boolDragEnd)
            {
                boolDragEnd = false;
                floatingButton2_clicked_counter = 0;
                googleMap.Clear();
                jmcMarker = googleMap.AddMarker(JMCdrone);
                googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(latLongJMCdrone, zoom));

                wPpolygon.Points.Clear();
                wPpolygon.InvokeStrokeWidth(7f);
                wPpolygon.InvokeStrokeColor(Color.DarkRed.ToArgb());
                wPpolygon.InvokeFillColor(0x330000FF);
                for (int i = 0; i < addWayPointCounter + 1; i++)
                {
                    wPpolygon.Add(wayPointArray[i]);
                }
                googleMap.AddPolygon(wPpolygon);

                for (int i = 1; i < addWayPointCounter + 1; i++)
                {
                    marker
                    .SetPosition(wayPointArray[i])
                    .SetTitle("wp_" + (i).ToString())
                    .SetSnippet(((float)DistanceTo(wayPointArray[i - 1].Latitude, wayPointArray[i - 1].Longitude, wayPointArray[i].Latitude, wayPointArray[i].Longitude)).ToString("F1") + " meters")
                    .Draggable(true)
                    .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));

                    googleMap.AddMarker(marker).ShowInfoWindow();
                }
            }
            if (flight_mode <= 9 && flight_mode >= 5)
            {
                if (startMission == 0)
                {
                    googleMap.Clear();
                    googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(latLongJMCdrone, zoom));
                    if (jmcMarker != null)
                    {
                        jmcMarker.Remove();
                    }
                    JMCdrone
                    .SetPosition(latLongJMCdrone)
                    .SetTitle("Distance to " + "wp_" + flyWayPointCounter.ToString())
                    .SetSnippet(((float)DistanceTo(latLongJMCdrone.Latitude, latLongJMCdrone.Longitude, wayPointArray[flyWayPointCounter].Latitude, wayPointArray[flyWayPointCounter].Longitude)).ToString("F1") + " meters")
                    .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.JMCdroneIcon));

                    jmcMarker = googleMap.AddMarker(JMCdrone);
                    jmcMarker.ShowInfoWindow();

                    home
                    .SetPosition(homeLatLong)
                    .SetTitle("HOME")
                    .SetSnippet("jmcHome")
                    .Draggable(false)
                    .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure));

                    googleMap.AddMarker(home);
                    for (int i = 1; i < addWayPointCounter + 1; i++)
                    {
                        marker
                        .SetPosition(wayPointArray[i])
                        .SetTitle("waypoint" + (i).ToString())
                        .Draggable(true)
                        .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));

                        googleMap.AddMarker(marker);
                    }
                    startMission = 1;
                    floatingButton2_clicked_counter = 0;
                    wPpolygon.Points.Clear();
                    wPpolygon.InvokeStrokeWidth(1f);
                    wPpolygon.InvokeStrokeColor(Color.DarkGreen.ToArgb());
                    wPpolygon.InvokeFillColor(0x33000011);
                    for (int i = 0; i < addWayPointCounter + 1; i++)
                    {
                        wPpolygon.Add(wayPointArray[i]);
                    }
                    googleMap.AddPolygon(wPpolygon);
                }
                else
                {
                    if (jmcMarker != null)
                    {
                        jmcMarker.Remove();
                    }
                    JMCdrone
                    .SetPosition(latLongJMCdrone)
                    .SetTitle("Distance to " + "wp_" + flyWayPointCounter.ToString())
                    .SetSnippet(((float)DistanceTo(latLongJMCdrone.Latitude, latLongJMCdrone.Longitude, wayPointArray[flyWayPointCounter].Latitude, wayPointArray[flyWayPointCounter].Longitude)).ToString("F1") + " meters");

                    jmcMarker = googleMap.AddMarker(JMCdrone);
                    jmcMarker.ShowInfoWindow();
                }
            }
            if (addWayPointCounter == wayPointArray.Length - 1)
            {
                addWayPointCounter = 0;
                floatingButton2_clicked_counter = 0;
                flyWayPointCounter = 0;
                startMission       = 0;
                googleMap.Clear();
                googleMap.AddMarker(JMCdrone);
                floatingButton4_clicked = false;
                floatingButton3.Show();
            }
            googleMap.MarkerDragEnd += GoogleMap_MarkerDragEnd;
        }
コード例 #29
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            Inicializa_MapFragment();
            //Definimos las ciudades en las cuales pondremos nuestros marcadores en el mapa
            MisCiudades.Add(new Ciudad_Marca("MÉXICO D.F.", "En su forma abreviada México, D. F., es la capital y sede de los poderes federales de los Estados Unidos Mexicanos.", new LatLng(19.430334, -99.13599), "p1"));
            MisCiudades.Add(new Ciudad_Marca("LEÓN", "Es una ciudad mexicana localizada  en el Estado de Guanajuato,México, en la región del Bajío.", new LatLng(21.12806, -101.689163), "p2"));
            MisCiudades.Add(new Ciudad_Marca("LAGOS DE MORENO", " Es un municipio y la ciudad más grande y poblada de la Región denominada Los Altos de Jalisco, ubicados en el estado mexicano de Jalisco.", new LatLng(21.36453, -101.939076), "p3"));
            MisCiudades.Add(new Ciudad_Marca("GUADALAJARA", "es una ciudad mexicana, capital del estado de Jalisco, así como principal localidad del área urbana denominada Zona Metropolitana de Guadalajara.", new LatLng(20.663626, -103.343754), "p4"));

            CargamosMarcadores();

            Button btnLinea    = FindViewById <Button> (Resource.Id.btnLinea);
            Button btnCirculo  = FindViewById <Button> (Resource.Id.btnCirculo);
            Button btnPoligono = FindViewById <Button> (Resource.Id.btnPoligono);

            txtPosicion = (TextView)FindViewById(Resource.Id.txtPosicion);



            btnLinea.Click += delegate {
                PolylineOptions rectOptions = new PolylineOptions();
                if (mMap != null)
                {
                    foreach (Ciudad_Marca ciudad in MisCiudades)
                    {
                        rectOptions.Add(ciudad.Ubicacion);
                    }

                    rectOptions.InvokeColor(Color.Red.ToArgb());
                    rectOptions.InvokeWidth(25);
                    rectOptions.Geodesic(true);

                    mMap.AddPolyline(rectOptions);
                }
            };

            btnCirculo.Click += delegate {
                if (mMap != null)
                {
                    foreach (Ciudad_Marca ciudad in MisCiudades)
                    {
                        CircleOptions circleOptions = new CircleOptions();
                        circleOptions.InvokeCenter(ciudad.Ubicacion);
                        circleOptions.InvokeRadius(10000);

                        circleOptions.InvokeStrokeWidth(10);
                        circleOptions.InvokeStrokeColor(Color.Blue.ToArgb());

                        Color micolorfill = Color.FromArgb(150, 149, 153, 225);
                        circleOptions.InvokeFillColor(micolorfill.ToArgb());

                        mMap.AddCircle(circleOptions);
                    }
                }
            };

            btnPoligono.Click += delegate {
                if (mMap != null)
                {
                    PolygonOptions Poligono = new PolygonOptions();
                    foreach (Ciudad_Marca ciudad in MisCiudades)
                    {
                        Poligono.Add(ciudad.Ubicacion);
                    }

                    Poligono.InvokeStrokeWidth(10);
                    Poligono.InvokeStrokeColor(Color.Green.ToArgb());

                    Color micolorfill = Color.FromArgb(150, 0, 255, 51);
                    Poligono.InvokeFillColor(micolorfill.ToArgb());

                    mMap.AddPolygon(Poligono);
                }
            };
        }
コード例 #30
0
        public async void OnMapReady(GoogleMap map)
        {
            mmap = map;

            mmap.MyLocationEnabled = true;
            mmap.MapType           = GoogleMap.MapTypeHybrid;
            mmap.UiSettings.ZoomControlsEnabled = true;

            //Set the farm positions
            PolygonOptions rectOptions = new PolygonOptions();

            rectOptions.Add(new LatLng(11.838600285438176, 75.62577920991211));
            rectOptions.Add(new LatLng(11.83865591985375, 75.62651107020247));
            rectOptions.Add(new LatLng(11.838092620878797, 75.6262055362958));
            rectOptions.Add(new LatLng(11.838092620881227, 75.62620529054104));
            rectOptions.Add(new LatLng(11.838252570075255, 75.6257434369438));
            rectOptions.Add(new LatLng(11.838600285438176, 75.62577920991211));

            // Market settings
            rectOptions.InvokeFillColor(int.Parse("6ca5ce59", System.Globalization.NumberStyles.HexNumber));
            rectOptions.InvokeStrokeWidth(1);

            // Add polygon to map
            mmap.AddPolygon(rectOptions);

            // Set the current camera position
            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Zoom(19);
            LatLng tempLocation = new LatLng(11.83865591985375, 75.6262055362958);

            builder.Target(tempLocation);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            mmap.MoveCamera(cameraUpdate);

            // Get weather details
            Weather weather = await GetWeather(11.83865591985375, 75.6262055362958);

            TextView weatherTV   = FindViewById <TextView>(Resource.Id.weather);
            TextView temperature = FindViewById <TextView>(Resource.Id.temperature);
            TextView wind        = FindViewById <TextView>(Resource.Id.wind);
            TextView humidity    = FindViewById <TextView>(Resource.Id.humidity);
            TextView visibility  = FindViewById <TextView>(Resource.Id.visibility);

            // Set weather details
            weatherTV.Text   = weather.Description;
            temperature.Text = weather.Temperature;
            wind.Text        = weather.Wind;
            humidity.Text    = weather.Humidity;
            visibility.Text  = weather.Visibility;

            // Set Status image
            var temperatureSummaryStatus = FindViewById <ImageView>(Resource.Id.temperatureSummaryStatus);

            temperatureSummaryStatus.SetImageResource(Resource.Drawable.toggle_checked);

            var soilSummaryStatus = FindViewById <ImageView>(Resource.Id.soilSummaryStatus);

            soilSummaryStatus.SetImageResource(Resource.Drawable.toggle_checked);

            var areaSummaryStatus = FindViewById <ImageView>(Resource.Id.areaSummaryStatus);

            areaSummaryStatus.SetImageResource(Resource.Drawable.toggle_checked);
        }