public void OnMapReady (GoogleMap googleMap) { map = googleMap; var circleOptions = new CircleOptions (); circleOptions.InvokeCenter (new LatLng (circle.Position.Latitude, circle.Position.Longitude)); circleOptions.InvokeRadius (circle.Radius); circleOptions.InvokeFillColor (0X66FF0000); circleOptions.InvokeStrokeColor (0X66FF0000); circleOptions.InvokeStrokeWidth (0); map.AddCircle (circleOptions); }
public void OnMapReady(GoogleMap googleMap) { map = googleMap; if (circle == null) { circle = new CustomCircle { Position = new Position {Longitude = 37.79752, Latitude = -122.40183 }, Radius = 3000D }; } var circleOptions = new CircleOptions(); circleOptions.InvokeCenter(new LatLng(circle.Position.Latitude, circle.Position.Longitude)); circleOptions.InvokeRadius(circle.Radius); circleOptions.InvokeFillColor(0X66B0171F); circleOptions.InvokeStrokeColor(0X66FF0000); circleOptions.InvokeStrokeWidth(0); map.AddCircle(circleOptions); }
private void HandleInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e) { CircleOptions circleOptions = new CircleOptions(); circleOptions.InvokeCenter(InMaui); circleOptions.InvokeRadius(100.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); }
/// <summary> /// Adds a circle to the map /// </summary> /// <param name="circle">The circle to add</param> private void AddCircle(TKCircle circle) { circle.PropertyChanged += CirclePropertyChanged; var circleOptions = new CircleOptions(); circleOptions.InvokeRadius(circle.Radius); circleOptions.InvokeCenter(circle.Center.ToLatLng()); if (circle.Color != Color.Default) { circleOptions.InvokeFillColor(circle.Color.ToAndroid().ToArgb()); } if (circle.StrokeColor != Color.Default) { circleOptions.InvokeStrokeColor(circle.StrokeColor.ToAndroid().ToArgb()); } circleOptions.InvokeStrokeWidth(circle.StrokeWidth); this._circles.Add(circle, this._googleMap.AddCircle(circleOptions)); }
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); } }; }
void AddCircles(IList circles) { var map = NativeMap; if (map == null) return; if (_circles == null) _circles = new List<ACircle>(); _circles.AddRange(circles.Cast<Circle>().Select(circle => { var opts = new CircleOptions(); opts.InvokeCenter(new LatLng(circle.Center.Latitude, circle.Center.Longitude)); opts.InvokeRadius(circle.Radius.Meters); opts.InvokeStrokeWidth(circle.StrokeWidth * _scaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps) opts.InvokeStrokeColor(circle.StrokeColor.ToAndroid()); opts.InvokeFillColor(circle.FillColor.ToAndroid()); //opts.Clickable(circle.IsClickable); var nativeCircle = map.AddCircle(opts); // associate pin with marker for later lookup in event handlers circle.Id = nativeCircle; return nativeCircle; })); }
void UpdateMap (int position) { if (googleMap == null) return; try { MapsInitializer.Initialize (this); } catch (GooglePlayServicesNotAvailableException e) { Console.WriteLine ("Google Play Services not available:" + e); error = true; #if !DEBUG Xamarin.Insights.Report (e, "GPS", "Not Available"); #endif return; } if (markerOptions == null) markerOptions = new MarkerOptions (); if (circleOptions == null) circleOptions = new CircleOptions (); var place = viewModel.Places [position]; var markerLatLong = new LatLng (place.Geometry.Location.Latitude, place.Geometry.Location.Longitude); if (marker == null) { markerOptions.SetTitle (place.Name); markerOptions.SetPosition (markerLatLong); marker = googleMap.AddMarker (markerOptions); } else { marker.Position = markerLatLong; marker.Title = place.Name; } var userLocation = new LatLng (viewModel.Position.Latitude, viewModel.Position.Longitude); if (locationCircle == null) { circleOptions.InvokeCenter (userLocation); circleOptions.InvokeRadius (radius); circleOptions.InvokeStrokeWidth (0); circleOptions.InvokeFillColor (Resources.GetColor (Resource.Color.accent)); locationCircle = googleMap.AddCircle (circleOptions); } else { locationCircle.Center = userLocation; locationCircle.Radius = radius; } if (!initMap) { var farthest = viewModel.Places [viewModel.Places.Count - 1]; var distance = farthest.GetDistance (userLocation.Latitude, userLocation.Longitude); radius = 20.0 * (distance / .45); radius = Math.Min (radius, 40.0); locationCircle.Radius = radius; var points = new LatLngBounds.Builder (); points.Include (userLocation); foreach (var p in viewModel.Places) points.Include (new LatLng (p.Geometry.Location.Latitude, p.Geometry.Location.Longitude)); var bounds = points.Build (); if (mapView.Width == 0) { initTry = 0; PostDelayInitMap (bounds); } else { googleMap.MoveCamera (CameraUpdateFactory.NewLatLngBounds (bounds, 0)); } initMap = true; } }
private void HandleMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e) { ClearMapOverlays (); Marker marker = e.Marker; int index = int.Parse (marker.Title); extendedMap.pin_Clicked (index ); Android.Graphics.Color clrb = new Android.Graphics.Color (12,92,169,130); Android.Graphics.Color clrr = new Android.Graphics.Color (204,27,39,130); PolygonOptions polygonOptions = new PolygonOptions(); switch (index) { case 0: CircleOptions circleOptions = new CircleOptions (); circleOptions.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng)); circleOptions.InvokeRadius (2000); circleOptions.InvokeFillColor (clrb.ToArgb ()); circleOptions.InvokeStrokeColor (clrr.ToArgb ()); circle = map.AddCircle (circleOptions); break; case 1: polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.InvokeFillColor (clrb.ToArgb()); polygonOptions.InvokeStrokeColor (clrr.ToArgb()); polygon = map.AddPolygon(polygonOptions); break; case 2: polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.005, extendedMap.pinDatas[index].lng)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.02, extendedMap.pinDatas[index].lng-0.02)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.InvokeFillColor (clrb.ToArgb()); polygonOptions.InvokeStrokeColor (clrr.ToArgb()); polygon = map.AddPolygon(polygonOptions); break; default: CircleOptions circleOptions2 = new CircleOptions (); circleOptions2.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng)); circleOptions2.InvokeRadius (2000); circleOptions2.InvokeFillColor (clrb.ToArgb ()); circleOptions2.InvokeStrokeColor (clrr.ToArgb ()); circle = map.AddCircle (circleOptions2); break; } }