private PolygonOptions GeoJsonPolygonToPolygon(GPolygon geoJsonPolygon) { System.Collections.ObjectModel.ReadOnlyCollection <LineString> coords = geoJsonPolygon?.Coordinates; if (coords == null || coords.Count() == 0) { return(null); } PolygonOptions polygonOptions = GetPolygonOptions(); LineString outer = coords.FirstOrDefault(); IEnumerable <LineString> inner = coords.Count > 1 ? coords.Skip(1) : null; foreach (IPosition coordinate in outer.Coordinates) { polygonOptions.Add(new LatLng(coordinate.Latitude, coordinate.Longitude)); } if (inner != null) { foreach (LineString linestring in inner) { var holes = linestring.Coordinates.Select(coordinate => new LatLng(coordinate.Latitude, coordinate.Longitude)).ToList(); polygonOptions.Holes.Add(holes.ToJavaList()); } } return(polygonOptions); }
protected override void OnInitialized() { mapOptions = new MapOptions() { Zoom = 16, Center = new LatLngLiteral() { Lat = -31.74230723298461, Lng = -60.494505564961386 }, MapTypeId = MapTypeId.Roadmap, ZoomControl = true, DisableDefaultUI = true }; polygonOptions = new PolygonOptions() { StrokeWeight = 0, FillOpacity = 0.45f, Draggable = true, Editable = true, FillColor = "#FF0000", StrokeColor = "#FF0000", }; }
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); }
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); })); }
/// <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)); } }
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); }
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 }
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); } }
private void DrawLoggedPosition(Position position) { System.Diagnostics.Debug.Write($"@@@@@ DrawLoggedPosition "); Tuple <int, int> index = customMap.GetIndexInGrid(position); if (drawnPositionsIndices.Contains(index)) { return; } drawnPositionsIndices.Add(index); PolygonOptions polygon = GetPolygon(); Tuple <Position, Position> visitedArea = customMap.GetAreaOnPosition(position); Position topLeft = visitedArea.Item1; Position botRight = visitedArea.Item2; polygon.Add(new LatLng(topLeft.Latitude, topLeft.Longitude)); polygon.Add(new LatLng(botRight.Latitude, topLeft.Longitude)); polygon.Add(new LatLng(botRight.Latitude, botRight.Longitude)); polygon.Add(new LatLng(topLeft.Latitude, botRight.Longitude)); NativeMap.AddPolygon(polygon); }
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); }
private PolygonOptions GetPolygon() { PolygonOptions polygon = new PolygonOptions(); polygon.InvokeFillColor(0x66FF0000); polygon.InvokeStrokeColor(0x660000FF); polygon.InvokeStrokeWidth(10.0f); return(polygon); }
private static PolygonOptions GetPolygoneRenderer() { var polygonOptions = new PolygonOptions(); polygonOptions.InvokeFillColor(0x66FF0000); polygonOptions.InvokeStrokeColor(0x66FF0000); polygonOptions.InvokeStrokeWidth(10.0f); return(polygonOptions); }
private void DrawPolygon() { PolygonOptions polygonOptions = GetPolygoneRenderer(); foreach (var position in _shapeCoordinates) { polygonOptions.Add(new LatLng(position.Latitude, position.Longitude)); } _polygon = NativeMap.AddPolygon(polygonOptions); }
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); }
/// <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); }
/// <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); }
public async void OnMapReady(GoogleMap googleMap) { float lat = (float)coordinates.Latitude; float lng = (float)coordinates.Longitude; LatLng coords = new LatLng(lat, lng); CameraPosition cameraPosition; using (CameraPosition.Builder builder = new CameraPosition.Builder()) { builder.Zoom(12); builder.Target(coords); cameraPosition = builder.Build(); } this.googleMap = googleMap; this.googleMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition)); this.googleMap.MapType = 3; this.googleMap.InfoWindowLongClick += GoogleMap_InfoWindowLongClick; MarkerOptions myLocationMarker = new MarkerOptions(); myLocationMarker.SetPosition(new LatLng(lat, lng)); myLocationMarker.SetTitle("My location"); this.googleMap.AddMarker(myLocationMarker); var airScraper = new AirspaceScraper(lng, lat, 120); airspace = await airScraper.ScrapeAsync(); hashes = new string[airspace.NOTAMZones.Length]; for (int x = 0; x < airspace.NOTAMZones.Length; x++) { PolygonOptions polygonOptions = new PolygonOptions(); for (int i = 0; i < airspace.NOTAMZones[x].Polypoints.Length; i++) { polygonOptions.Add(new LatLng(airspace.NOTAMZones[x].Polypoints[i].Latitude, airspace.NOTAMZones[x].Polypoints[i].Longitude)); } hashes[x] = $"{airspace.NOTAMZones[x].Latitude}{airspace.NOTAMZones[x].Longitude}"; MarkerOptions notamMarker = new MarkerOptions(); notamMarker.SetPosition(new LatLng(airspace.NOTAMZones[x].Latitude, airspace.NOTAMZones[x].Longitude)); notamMarker.SetTitle($"{airspace.NOTAMZones[x].Reference} - {airspace.NOTAMZones[x].Meaning}"); this.googleMap.AddMarker(notamMarker); this.googleMap.AddPolygon(polygonOptions); } }
public void crearPoligono(GoogleMap map) { PolygonOptions rectOptions = new PolygonOptions(); rectOptions.Add(new LatLng(37.35, -122.0)); rectOptions.Add(new LatLng(37.45, -122.0)); rectOptions.Add(new LatLng(37.45, -122.2)); rectOptions.Add(new LatLng(37.35, -122.2)); // notice we don't need to close off the polygon map.AddPolygon(rectOptions); }
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); }
private void BuildPolygon(PolygonOptions polygon) { Log.Debug("BuildPolygon", "Building polygon"); gameActivity.gamePlayArea.polygonsNode = gameActivity.gamePlayArea.polygons.AddLast(gameActivity.googleMap.AddPolygon(polygon)); if (gameActivity.gamePlayArea.playAreaDrawnBool == false) { gameActivity.initialArea = (float)Static.Maths.PolygonArea(gameActivity.gamePlayArea.vertices); gameActivity.area = (int)((Static.Maths.PolygonArea(gameActivity.gamePlayArea.vertices) / gameActivity.initialArea) * 100); gameActivity.gamePlayArea.playAreaDrawnBool = true; } }
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); }
//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; }
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); }
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; }
private void AddPolygonGeometryToMap(GPolygon polygonGeometry) { PolygonOptions polygon = GeoJsonPolygonToPolygon(polygonGeometry); if (polygon != null) { try { APolygon aPolygon = NativeMap.AddPolygon(polygon); _polygons.Add(polygonGeometry, aPolygon); } catch (Exception) { Console.WriteLine("Failed to add polygon to map or dictionary"); } } }
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); }
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); }
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; } }
public MapOverlay(Cell cell) { CellID = cell.ID; // Set cell overlay options cellPolygonOptions = new PolygonOptions(); cellPolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude)); //first rectangle point cellPolygonOptions.Add(new LatLng((double)cell.Latitude, (double)cell.Longitude + (double)GameModel.FrontierInterval)); cellPolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude + (double)GameModel.FrontierInterval)); cellPolygonOptions.Add(new LatLng((double)cell.Latitude + (double)GameModel.FrontierInterval, (double)cell.Longitude)); //automatically connects last two points cellPolygonOptions.InvokeZIndex(100); // Set mine overlay options LatLng circleCenter = new LatLng((double)cell.Latitude + ((double)GameModel.FrontierInterval / 2), (double)cell.Longitude + ((double)GameModel.FrontierInterval / 2)); mineCircleOptions = new CircleOptions(); mineCircleOptions.InvokeCenter(circleCenter); mineCircleOptions.InvokeRadius(3); mineCircleOptions.InvokeStrokeWidth(6); mineCircleOptions.InvokeStrokeColor(Color.White); mineCircleOptions.InvokeZIndex(200); // Set antimine overlay options antiMineTriangleOptions = new PolygonOptions(); antiMineTriangleOptions.Add(new LatLng(((double)cell.Latitude + ((double)GameModel.FrontierInterval) * .75), ((double)cell.Longitude + (double)GameModel.FrontierInterval / 2))); antiMineTriangleOptions.Add(new LatLng(((double)cell.Latitude + ((double)GameModel.FrontierInterval) * .25), ((double)cell.Longitude + (double)GameModel.FrontierInterval * .25))); antiMineTriangleOptions.Add(new LatLng(((double)cell.Latitude + ((double)GameModel.FrontierInterval) * .25), ((double)cell.Longitude + (double)GameModel.FrontierInterval * .75))); antiMineTriangleOptions.InvokeStrokeWidth(6); antiMineTriangleOptions.InvokeStrokeColor(Color.White); antiMineTriangleOptions.InvokeZIndex(200); UpdateColor(cell.HoldStrength, cell.TeamID); cellPolygonOptions.InvokeStrokeWidth(0); if (cell.TeamID == GameModel.Player.Team.ID) { MapOverlayClickHandler = new FriendlyOverlayClickHandler(); } else { MapOverlayClickHandler = new EnemyOverlayClickHandler(); } }
public void SetPolygon(LatLng[] vertices) { Log.Debug("SetPolygon", "Setting polygon positions"); PolygonOptions polygon = new PolygonOptions(); for (int i = 0; i < vertices.Length; i++) { polygon.Add(vertices[i]); } if (setActivity.setPlayArea.polygon == null) { BuildPolygon(polygon); } else { setActivity.setPlayArea.polygon.Points = vertices; } }