//public void OnClusterItemUpdated(Person person, Marker marker) //{ // // Same implementation as onBeforeClusterItemRendered() (to update cached markers) // marker.SetIcon(getItemIcon(person)); // marker.Title = person.Name; //} /** * Get a descriptor for a single person (i.e., a marker outside a cluster) from their * profile photo to be used for a marker icon * * @param person person to return an BitmapDescriptor for * @return the person's profile photo as a BitmapDescriptor */ private BitmapDescriptor getItemIcon(Person person) { mImageView.SetImageResource(person.profilePhoto); Bitmap icon = mIconGenerator.MakeIcon(); return(BitmapDescriptorFactory.FromBitmap(icon)); }
protected override void OnBeforeClusterRendered(ICluster p0, MarkerOptions p1) { List <Drawable> photos = new List <Drawable>(System.Math.Min(4, p0.Size)); int width = dimension; int height = dimension; foreach (var person in p0.Items) { if (photos.Count == 4) { return; } var p = person as Person; Drawable drawable = context.GetDrawable(p.Photo); drawable.SetBounds(0, 0, width, height); photos.Add(drawable); } MultiDrawable multiDrawable = new MultiDrawable(photos); multiDrawable.SetBounds(0, 0, width, height); clusterImageView.SetImageDrawable(multiDrawable); Bitmap icon = clusterIconGenerator.MakeIcon(p0.Size.ToString()); p1.SetIcon(BitmapDescriptorFactory.FromBitmap(icon)); }
//protected override void OnClusterUpdated(ICluster cluster, Marker marker) //{ // // Same implementation as onBeforeClusterRendered() (to update cached markers) // marker.SetIcon(getClusterIcon(cluster)); //} /** * Get a descriptor for multiple people (a cluster) to be used for a marker icon. Note: this * method runs on the UI thread. Don't spend too much time in here (like in this example). * * @param cluster cluster to draw a BitmapDescriptor for * @return a BitmapDescriptor representing a cluster */ private BitmapDescriptor getClusterIcon(ICluster cluster) { List <Drawable> profilePhotos = new List <Drawable>(Math.Min(4, cluster.Size)); int width = mDimension; int height = mDimension; foreach (Person p in cluster.Items) { // Draw 4 at most. if (profilePhotos.Count == 4) { break; } Drawable drawable = context.Resources.GetDrawable(p.profilePhoto); drawable.SetBounds(0, 0, width, height); profilePhotos.Add(drawable); } MultiDrawable multiDrawable = new MultiDrawable(profilePhotos); multiDrawable.SetBounds(0, 0, width, height); mClusterImageView.SetImageDrawable(multiDrawable); Bitmap icon = mClusterIconGenerator.MakeIcon(cluster.Size.ToString()); return(BitmapDescriptorFactory.FromBitmap(icon)); }
private void addIcon(IconGenerator iconFactory, string text, LatLng position) { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.SetIcon(BitmapDescriptorFactory.FromBitmap(iconFactory.MakeIcon(text))); markerOptions.SetPosition(position); markerOptions.Anchor(iconFactory.AnchorU, iconFactory.AnchorV); getMap().AddMarker(markerOptions); }
protected override void OnBeforeClusterItemRendered(Java.Lang.Object p0, MarkerOptions p1) { // Draw a single person. // Set the info window to show their name. var person = p0 as Person; imageView.SetImageResource(person.Photo); Bitmap icon = iconGenerator.MakeIcon(); p1.SetIcon(BitmapDescriptorFactory.FromBitmap(icon)).SetTitle(person.Name); }
void addIcon(IconGenerator iconFactory, string text, LatLng position) { return; var markerOptions = new MarkerOptions(); markerOptions.SetIcon(BitmapDescriptorFactory.FromBitmap(iconFactory.MakeIcon(text))); markerOptions.SetPosition(position); markerOptions.Anchor(iconFactory.AnchorU, iconFactory.AnchorV); this.map.AddMarker(markerOptions); }
protected async override void OnBeforeClusterRendered(ICluster p0, MarkerOptions p1) { base.OnBeforeClusterRendered(p0, p1); var customPin = _mapRenderer.FormsMap.GetClusteredPin?.Invoke(null, p0.Items.OfType <TKMarker>().Select(i => i.Pin)); if (customPin == null) { p1.SetIcon(BitmapDescriptorFactory.FromBitmap(_iconGenerator.MakeIcon(p0.Size.ToString()))); } else { var tempMarker = new TKMarker(customPin, _context); await tempMarker.InitializeMarkerOptionsAsync(p1, false); } }
public StationRenderer(Context context, GoogleMap map, ClusterManager clusterManager) : base(context, map, clusterManager) { _context = context; _map = map; _clusterManager = clusterManager; _contractService = SimpleIoc.Default.GetInstance<IContractService>(); _settingsService = SimpleIoc.Default.GetInstance<ISettingsService>(); _iconGenRed = new IconGenerator(_context); _iconGenGreen = new IconGenerator(_context); _iconGenOrange = new IconGenerator(_context); _iconGenGrey = new IconGenerator(_context); _iconGenGreyLowAlpha = new IconGenerator(_context); //// Define the size you want from dimensions file //var shapeDrawable = ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.station, null); //iconGen.SetBackground(shapeDrawable); ////// Create a view container to set the size _iconGenRed.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationRed, null)); _iconGenOrange.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationOrange, null)); _iconGenGreen.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGreen, null)); _iconGenGrey.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGrey, null)); _iconGenGreyLowAlpha.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGreyAlpha, null)); _iconRed = _iconGenRed.MakeIcon(); _iconGreen = _iconGenGreen.MakeIcon(); _iconOrange = _iconGenOrange.MakeIcon(); _iconGrey = _iconGenGrey.MakeIcon(); _iconGreyLowAlpha = _iconGenGreyLowAlpha.MakeIcon(); var textView = new TextView(context); textView.SetTextAppearance(_context, Resource.Style.iconGenText); _textPaint.AntiAlias = true; _textPaint.SetARGB(255, 0, 0, 0); _textPaint.TextSize = textView.TextSize; _textPaint.TextAlign = Paint.Align.Center; //_textPaint.SetTypeface(textView.Typeface); _textPaint.SetTypeface(Typeface.CreateFromAsset(_context.Assets, "fonts/Roboto-Bold.ttf")); }
public StationRenderer(Context context, GoogleMap map, ClusterManager clusterManager) : base(context, map, clusterManager) { _context = context; _map = map; _clusterManager = clusterManager; _contractService = SimpleIoc.Default.GetInstance <IContractService>(); _settingsService = SimpleIoc.Default.GetInstance <ISettingsService>(); _iconGenRed = new IconGenerator(_context); _iconGenGreen = new IconGenerator(_context); _iconGenOrange = new IconGenerator(_context); _iconGenGrey = new IconGenerator(_context); _iconGenGreyLowAlpha = new IconGenerator(_context); //// Define the size you want from dimensions file //var shapeDrawable = ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.station, null); //iconGen.SetBackground(shapeDrawable); ////// Create a view container to set the size _iconGenRed.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationRed, null)); _iconGenOrange.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationOrange, null)); _iconGenGreen.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGreen, null)); _iconGenGrey.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGrey, null)); _iconGenGreyLowAlpha.SetBackground(ResourcesCompat.GetDrawable(_context.Resources, Resource.Drawable.stationGreyAlpha, null)); _iconRed = _iconGenRed.MakeIcon(); _iconGreen = _iconGenGreen.MakeIcon(); _iconOrange = _iconGenOrange.MakeIcon(); _iconGrey = _iconGenGrey.MakeIcon(); _iconGreyLowAlpha = _iconGenGreyLowAlpha.MakeIcon(); var textView = new TextView(context); textView.SetTextAppearance(_context, Resource.Style.iconGenText); _textPaint.AntiAlias = true; _textPaint.SetARGB(255, 0, 0, 0); _textPaint.TextSize = textView.TextSize; _textPaint.TextAlign = Paint.Align.Center; //_textPaint.SetTypeface(textView.Typeface); _textPaint.SetTypeface(Typeface.CreateFromAsset(_context.Assets, "fonts/Roboto-Bold.ttf")); }
//private string _parameterText; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _locator = CrossGeolocator.Current; // New in iOS 9 allowsBackgroundLocationUpdates must be set if you are running a background agent to track location. I have exposed this on the Geolocator via: // disable because it drill down the battery very quickly _locator.AllowsBackgroundUpdates = false; _locator.DesiredAccuracy = 50; _locator.PositionChanged -= Locator_PositionChanged; _locator.PositionChanged += Locator_PositionChanged; // parse params to show any shared location if it exists ParseIntent(); var tintManager = new SystemBarTintManager(this); // set the transparent color of the status bar, 30% darker tintManager.SetTintColor(Color.ParseColor("#30000000")); tintManager.SetNavigationBarTintEnabled(true); tintManager.StatusBarTintEnabled = true; // prevent the soft keyboard from pushing the view up Window.SetSoftInputMode(SoftInput.AdjustNothing); // prepare icons for location / compass button var iconGenerator = new IconGenerator(this); iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_location, null)); _iconUserLocation = iconGenerator.MakeIcon(); iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_compass, null)); _iconCompass = iconGenerator.MakeIcon(); //var uiOptions = (int)this.Window.DecorView.SystemUiVisibility; //var newUiOptions = (int)uiOptions; //newUiOptions &= ~(int)SystemUiFlags.LowProfile; //newUiOptions &= ~(int)SystemUiFlags.Fullscreen; //newUiOptions &= ~(int)SystemUiFlags.HideNavigation; //newUiOptions &= ~(int)SystemUiFlags.Immersive; //newUiOptions |= (int)SystemUiFlags.ImmersiveSticky; //this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; //Window.SetFlags(WindowManagerFlags.LayoutNoLimits, WindowManagerFlags.LayoutNoLimits); var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); //toolbar.Background.SetAlpha(200); ViewCompat.SetElevation(toolbar, 6f); SetSupportActionBar(toolbar); //Enable support action bar to display hamburger and back arrow // http://stackoverflow.com/questions/28071763/toolbar-navigation-hamburger-icon-missing _drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //_drawerToggle = new CustomActionBarDrawerToggle(this, _drawerLayout, toolbar, Resource.String.ApplicationName, Resource.String.ApplicationName); //_drawerToggle.DrawerIndicatorEnabled = true; _drawerLayout.SetDrawerListener(new CustomDrawerToggle(this)); //Enable support action bar to display hamburger var burgerImage = FindViewById<ImageButton>(Resource.Id.burgerImage); burgerImage.SetOnClickListener(new HomeButtonClickListener(this)); // SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu); SupportActionBar.SetHomeButtonEnabled(false); SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetDisplayShowCustomEnabled(false); navigationView = FindViewById<NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(new NavigationItemSelectedListener(this)); _bikesButton = FindViewById<FloatingActionButton>(Resource.Id.bikesButton); _bikesButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light)); _bikesButton.Click += BikesButton_Click; _parkingButton = FindViewById<FloatingActionButton>(Resource.Id.parkingButton); _parkingButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light)); _parkingButton.Click += ParkingButton_Click; _locationButton = FindViewById<FloatingActionButton>(Resource.Id.locationButton); _locationButton.BackgroundTintList = ColorStateList.ValueOf(Color.White); _locationButton.SetColorFilter(Color.Gray); _searchProgressBar = FindViewById<ProgressBar>(Resource.Id.searchProgressBar); // Doesn't work on Kitkat 4.4, use SetColorFilter instead //_locationButton.ImageTintList = ColorStateList.ValueOf(Color.Black); _locationButton.Click += LocationButton_Click; _tileButton = FindViewById<FloatingActionButton>(Resource.Id.tileButton); _tileButton.BackgroundTintList = ColorStateList.ValueOf(Color.White); _tileButton.SetColorFilter(Color.DarkGray); _tileButton.Click += TileButton_Click; var parent = (View)_tileButton.Parent; // Gets the parent view and posts a Runnable on the UI thread. // This ensures that the parent lays out its children before calling the getHitRect() method. // The getHitRect() method gets the child's hit rectangle (touchable area) in the parent's coordinates. parent.Post(() => { var touchRect = new Rect(); _tileButton.GetHitRect(touchRect); touchRect.Top -= 200; touchRect.Left -= 200; touchRect.Bottom += 200; touchRect.Right += 200; parent.TouchDelegate = new TouchDelegate(touchRect, _tileButton); }); _currentTileName = FindViewById<TextView>(Resource.Id.currentTileName); _currentTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder); _disappearTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.disappearAnimation); _currentTileNameAnimation.AnimationEnd += _currentTileNameAnimation_AnimationEnd; UnStickUserLocation(); AutoCompleteSearchPlaceTextView = FindViewById<AutoCompleteTextView>(Resource.Id.autoCompleteSearchPlaceTextView); AutoCompleteSearchPlaceTextView.ItemClick += AutoCompleteSearchPlaceTextView_ItemClick; googlePlacesAutocompleteAdapter = new GooglePlacesAutocompleteAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line); AutoCompleteSearchPlaceTextView.Adapter = googlePlacesAutocompleteAdapter; Observable.FromEventPattern(AutoCompleteSearchPlaceTextView, "TextChanged") .Throttle(TimeSpan.FromMilliseconds(300)) .Where(x => AutoCompleteSearchPlaceTextView.Text.Length >= 2) .Subscribe(async x => { try { RunOnUiThread(() => { _searchProgressBar.Visibility = ViewStates.Visible; }); using (var client = new HttpClient(new NativeMessageHandler())) { var response = await client.GetAsync(strAutoCompleteGoogleApi + AutoCompleteSearchPlaceTextView.Text + "&key=" + strGoogleApiKey).ConfigureAwait(false); var responseBodyAsText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var predictions = JsonConvert.DeserializeObject<PlaceApiModel>(responseBodyAsText).predictions.ToList(); googlePlacesAutocompleteAdapter.Results = predictions; if (AutoCompleteSearchPlaceTextView.Text.Length >= 2) { RunOnUiThread(() => { googlePlacesAutocompleteAdapter.NotifyDataSetChanged(); EndPlacesSearch(); }); } } } catch { RunOnUiThread(() => { EndPlacesSearch(); }); } }); //navigationView.NavigationItemSelected += (sender, e) => //{ // e.MenuItem.SetChecked(true); // //react to click here and swap fragments or navigate // drawerLayout.CloseDrawers(); //}; // trigger the creation of the injected dependencies _settingsService = SimpleIoc.Default.GetInstance<ISettingsService>(); _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>(); }