public View GetInfoWindow(Marker marker) { if (marker == null) { return(null); } //update everytime, drawcircle need it selectedCoordinates = new GeofenceModel { LatLng = new LatLng(marker.Position.Latitude, marker.Position.Longitude) }; View mapInfoView = activity.LayoutInflater.Inflate(Resource.Layout.map_info_view, null); var radiusBar = activity.FindViewById <SeekBar>(Resource.Id.radiusBar); if (radiusBar.Visibility == Android.Views.ViewStates.Invisible) { radiusBar.Visibility = Android.Views.ViewStates.Visible; radiusBar.SetProgress(30, true); } activity.FindViewById <SeekBar>(Resource.Id.radiusBar)?.SetProgress(30, true); activity.DrawCircleOnMap(selectedCoordinates); Button button = mapInfoView.FindViewById <Button>(Resource.Id.btnInfoWindow); button.Click += btnInfoWindow_ClickAsync; return(mapInfoView); }
/// <summary> /// Initializes a new instance of the <see cref="GeofenceSettingsPage"/> class. /// </summary> public GeofenceSettingsPage() { _oSelectedGeofenceCommand = null; InitializeComponent(); App.ShowToast(AppResources.title_add_location); swEnableGeofence.IsToggled = App.AppSettings.GeofenceEnabled; swEnableGeofence.Toggled += (sender, args) => { App.AppSettings.GeofenceEnabled = swEnableGeofence.IsToggled; }; swEnableGeofenceNotifications.IsToggled = App.AppSettings.GeofenceNotificationsEnabled; swEnableGeofenceNotifications.Toggled += (sender, args) => { App.AppSettings.GeofenceNotificationsEnabled = swEnableGeofenceNotifications.IsToggled; }; _oListSource = App.AppSettings.Geofences; if (_oListSource == null) { _oListSource = new List <GeofenceModel>(); } listView.ItemsSource = _oListSource; }
/// <summary> /// Connect device to Geofence Command /// </summary> /// <param name="sender">The sender<see cref="object"/></param> /// <param name="e">The e<see cref="EventArgs"/></param> private async void btnConnect_Clicked(object sender, EventArgs e) { _oSelectedGeofenceCommand = (Models.GeofenceModel)((TintedCachedImage)sender).BindingContext; var oSwitchPopup = new SwitchPopup(); oSwitchPopup.DeviceSelectedMethod += DelegateMethod; await Navigation.PushAsync(oSwitchPopup); }
public void DrawCircleOnMap(GeofenceModel geoModel) { this.selectedCoordinates = geoModel; if (circle != null) { circle.Remove(); circle = null; } CircleOptions circleOptions = new CircleOptions() .InvokeCenter(geoModel.LatLng) .InvokeRadius(geoModel.Radius) .InvokeFillColor(Color.Argb(50, 0, 14, 84)) .InvokeStrokeColor(Color.Yellow) .InvokeStrokeWidth(15); circle = hMap.AddCircle(circleOptions); }
public void OnMapReady(HuaweiMap map) { hMap = map; hMap.MapType = HuaweiMap.MapTypeNormal; hMap.UiSettings.MyLocationButtonEnabled = true; hMap.UiSettings.CompassEnabled = true; hMap.UiSettings.ZoomControlsEnabled = true; hMap.UiSettings.ZoomGesturesEnabled = true; hMap.MyLocationEnabled = true; hMap.MapClick += HMap_MapClick; if (selectedCoordinates == null) { selectedCoordinates = new GeofenceModel { LatLng = CurrentPosition, Radius = 30 } } ; }
/// <summary> /// On location choosen /// </summary> private void OnLocationChoosen(int radius, string address, Xamarin.Forms.Maps.Position location) { if (location == null) { return; } if (string.IsNullOrEmpty(address)) { address = $"{location.Latitude} {location.Longitude}"; } var geofence = new GeofenceModel() { Id = address.GetHashCode().ToString(), Name = address, Latitude = location.Latitude, Longitude = location.Longitude, Enabled = true, Radius = radius, }; _oListSource.Add(geofence); App.ShowToast(AppResources.noSwitchSelected_explanation); SaveAndRefresh(); }
public void AddGeofences(GeofenceModel geofenceModel) { //Set parameters geofenceModel.Id = Guid.NewGuid().ToString(); if (geofenceModel.Conversion == 5) //Expiration value that indicates the geofence should never expire. { geofenceModel.Timeout = Geofence.GeofenceNeverExpire; } else { geofenceModel.Timeout = 10000; } List <IGeofence> geofenceList = new List <IGeofence>(); //Geofence Service GeofenceService geofenceService = LocationServices.GetGeofenceService(activity); PendingIntent pendingIntent = CreatePendingIntent(); GeofenceBuilder somewhereBuilder = new GeofenceBuilder() .SetUniqueId(geofenceModel.Id) .SetValidContinueTime(geofenceModel.Timeout) .SetRoundArea(geofenceModel.LatLng.Latitude, geofenceModel.LatLng.Longitude, geofenceModel.Radius) .SetDwellDelayTime(10000) .SetConversions(geofenceModel.Conversion);; //Create geofence request geofenceList.Add(somewhereBuilder.Build()); GeofenceRequest geofenceRequest = new GeofenceRequest.Builder() .CreateGeofenceList(geofenceList) .Build(); //Register geofence //Task geoTask = geofenceService.CreateGeofenceList(geofenceRequest, pendingIntent); //geoTask.AddOnSuccessListener(new CreateGeoSuccessListener(activity)); //geoTask.AddOnFailureListener(new CreateGeoFailListener(activity)); }