private void AddMarkers(string category) { _googleMap.Clear(); LatLng userLatLng = new LatLng(_userLat, _userLng); AddUserMarker(userLatLng); _selectedPlaces = _placeDatabase.GetAllPlacesByCategory(category); foreach (Place place in _selectedPlaces) { LatLng placeLatLng = new LatLng(place.Lat, place.Lng); double distance = Math.Round(DistanceHelper.CalculateDistance(GetLastKnownLocation().Latitude, GetLastKnownLocation().Longitude, place.Lat, place.Lng), 2); var placeMarker = new MarkerOptions(); placeMarker.SetPosition(placeLatLng) .SetTitle(place.Name) .SetSnippet("rating: " + place.Rating.ToString() + ", vzdialené: " + distance.ToString() + "km") .SetIcon(BitmapDescriptorFactory.FromResource(GetIconByCategory(place.Category))); _googleMap.AddMarker(placeMarker); } }
public static ObservableCollection <Pin> ToGoogleMapsPinsWithPunctualityColorsPins( this IEnumerable <BusStop> busStops) { var result = new ObservableCollection <Pin>(); foreach (var busStop in busStops) { var punctualityPercentage = int.Parse(busStop.PunctualityPercentage.TrimEnd('%')); string iconName = "MapIcons/mapIconAverage.png"; if (punctualityPercentage < 50) { iconName = _mapIcons[0]; } else if (punctualityPercentage < 80) { iconName = _mapIcons[1]; } else if (punctualityPercentage >= 80) { iconName = _mapIcons[2]; } if (string.IsNullOrEmpty(busStop.Label)) { busStop.Label = " "; } result.Add(new Pin { Label = busStop.Label, Address = busStop.Address, Position = new Position(busStop.Latitude, busStop.Longitude), Icon = BitmapDescriptorFactory.FromBundle(iconName) }); } return(result); }
public void setSourceMarker(string mSource) { while (!isMapAvailable) { ; } double slatd, slngd; if (slat != "") { slatd = Convert.ToDouble(slat); } else { slatd = 17.4622; } if (slng != "") { slngd = Convert.ToDouble(slng); } else { slngd = 78.3568; } if (!hasSourceSet) { mLatLngSource = new LatLng(slatd, slngd); mOptions[1] = new MarkerOptions() .SetPosition(mLatLngSource) .SetTitle(msourceRecieved) .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)) .Draggable(true); gMap.AddMarker(mOptions[1]); hasSourceSet = true; CameraUpdate mCameraUpdate1 = CameraUpdateFactory.NewLatLngZoom(mLatLngSource, 12); gMap.MoveCamera(mCameraUpdate1); } }
protected override void OnMapReady(GoogleMap googleMap) { map = googleMap; //element.SetNativeContext(this); map.MarkerClick += Map_MarkerClick; CreatePolygon(element.RouteCoordinates); foreach (var circle in element.Circles) { CreateCircle(circle); } element.Circles.CollectionChanged += (ss, ee) => { if (ee.NewItems == null) { return; } foreach (Circle circle in ee.NewItems) { CreateCircle(circle); } }; //map.Clear(); var bd = Forms.Context.Resources.GetDrawable(element.ImageSource) as BitmapDrawable; foreach (var pin in element.CustomPins) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (bd != null && bd.Bitmap != null) { marker.SetIcon(BitmapDescriptorFactory.FromBitmap(bd.Bitmap)); } map.AddMarker(marker); } bd.Dispose(); }
private void setUpMap() { LatLng SHANGHAI = new LatLng(31.238068, 121.501654); aMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(SHANGHAI, 14)); aMap.MapType = AMap.MapTypeNormal; var pins = myAMapPage.Pins; Drawable d = Resources.GetDrawable(Resource.Drawable.red_location); Bitmap bitmap = ((BitmapDrawable)d).Bitmap; LatLng latLng1; foreach (UserTaskEntInfo pin in pins) { latLng1 = new LatLng(pin.Longitude ?? 31.238068, pin.Latitude ?? 121.501654); var markOption = new MarkerOptions(); markOption.InvokeIcon(BitmapDescriptorFactory.FromBitmap(bitmap)); markOption.InvokeTitle(pin.Name); markOption.InvokePosition(latLng1); var fix = aMap.AddMarker(markOption); fix.ShowInfoWindow(); } aMap.SetLocationSource(this); // 设置定位监听 aMap.UiSettings.MyLocationButtonEnabled = true; // 设置默认定位按钮是否显示 aMap.MyLocationEnabled = true; // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false //aMap.SetMyLocationType(AMap.LOCATION_TYPE_LOCATE);//设置定位的类型为跟随模式,3D地图才有; // 自定义系统定位小蓝点 MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.InvokeMyLocationIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.location_marker)); // 设置小蓝点的图标 myLocationStyle.InvokeStrokeColor(Android.Graphics.Color.Black); // 设置圆形的边框颜色 myLocationStyle.InvokeRadiusFillColor(Android.Graphics.Color.Argb(100, 0, 0, 180)); // 设置圆形的填充颜色 myLocationStyle.InvokeStrokeWidth(1.0f); // 设置圆形的边框粗细 aMap.SetMyLocationStyle(myLocationStyle); }
async void InitialyzeSites() { //Initialise first value Pin pinPobo = new Pin() { Type = PinType.Place, Label = "El Pobo", Address = "El Pobo, Teruel, Spain", Position = new Position(40.507391d, -0.860525d), Rotation = 33.3f, Tag = "id_tokyo", }; map.Pins.Add(pinPobo); var contents = await mapPageViewModel.LoadSites(); if (contents != null) { foreach (var item in contents) { Pin SitePins = new Pin() { Label = "", Address = item.Label, Type = PinType.Place, Icon = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("CarPins.png") : BitmapDescriptorFactory.FromView(new Image() { Source = item.Icon, WidthRequest = 30, HeightRequest = 30 }), Position = new Position(Convert.ToDouble(item.Latitude), Convert.ToDouble(item.Longitude)), }; map.Pins.Add(SitePins); } } map.MoveToRegion(MapSpan.FromCenterAndRadius(pinPobo.Position, Distance.FromMeters(280))); }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var androidMapView = (MapView)Control; var formsMap = (CustomMap)sender; if (e.PropertyName.Equals("VisibleRegion") && !_isDrawnDone) { androidMapView.Map.Clear(); androidMapView.Map.MarkerClick += HandleMarkerClick; androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; var formsPins = formsMap.CustomPins; foreach (var formsPin in formsPins) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude)); markerWithIcon.SetTitle(formsPin.Label); markerWithIcon.SetSnippet(formsPin.Address); if (!string.IsNullOrEmpty(formsPin.PinIcon)) { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromAsset(String.Format("{0}.png", formsPin.PinIcon))); } else { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); } androidMapView.Map.AddMarker(markerWithIcon); } _isDrawnDone = true; } }
public void OnMapReady(GoogleMap googleMap) { mvMap = googleMap; LatLng latlng = new LatLng(39.519962, -119.797516); CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 11); mvMap.MoveCamera(camera); //place a pin where the event is located //loop through each of the events and place a pin. foreach (KeyValuePair <string, Event> x in mapEvents) { LatLng newPin = new LatLng(x.Value.Latitude, x.Value.Longitude); MarkerOptions options = new MarkerOptions().SetPosition(newPin). SetTitle(x.Value.Name + " - " + x.Value.Username).SetSnippet(x.Value.Details); if (x.Value.Username == userName) { options.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); } Marker newMarker = mvMap.AddMarker(options); newMarker.Tag = x.Key; } mvMap.MarkerClick += MvMap_MarkerClick; //mvMap.AddMarker(options); //epMap.SetOnMapLongClickListener(this); }
protected override void OnMapReady(GoogleMap map) { if (mapDrawn) { return; } base.OnMapReady(map); NativeMap.SetInfoWindowAdapter(this); NativeMap.MarkerClick += OnMarkerClick; NativeMap.InfoWindowClick += OnInfoWindowClick; pins = new List <Pin>(formsMap.Pins); CoworkingClicked += formsMap.OnCoworking; formsMap.PinsUpdated += OnPinsUpdate; bool isEnabled = DependencyService.Get <IPermissionRequester>().IsGPSEnabled(); if (me != null) { me.Remove(); } if (isEnabled) { var ret = LocationHelper.GetLocation(); var marker = new MarkerOptions(); marker.SetPosition(new LatLng(ret.Latitude, ret.Longitude)); var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.HereIcon); marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateScaledBitmap(bitmap, 350, 200, false))); marker.Draggable(false); me = NativeMap.AddMarker(marker); } mapDrawn = true; }
public void OnMapReady(GoogleMap googleMap) { _map = googleMap; _map.UiSettings.CompassEnabled = false; _map.UiSettings.MyLocationButtonEnabled = true; _map.UiSettings.MapToolbarEnabled = true; _map.MyLocationEnabled = true; var myLocation = new MapMarkerEntity(); Position getPosition = GetCurrentPosition().Result; var builder = new LatLngBounds.Builder(); myLocation.Latitude = getPosition.Latitude; myLocation.Longitude = getPosition.Longitude; builder.Include(new LatLng(myLocation.Latitude, myLocation.Longitude)); _map.AddMarker(new MarkerOptions().SetPosition(new LatLng(myLocation.Latitude, myLocation.Longitude)).SetTitle($"{ViewModel.TaskId}") .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen))); if (ViewModel.MarkerList != null && ViewModel.MarkerList.Any()) { foreach (MapMarkerEntity coord in ViewModel.MarkerList) { _map.AddMarker(new MarkerOptions().SetPosition(new LatLng(coord.Latitude, coord.Longitude)) .SetTitle($"{ViewModel.TaskId}")); builder.Include(new LatLng(coord.Latitude, coord.Longitude)); } } LatLngBounds bound = builder.Build(); _map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bound, Constants.MapPadding)); _map.MapClick += ClickOnMap; }
private void zoekNieuweKlanten() { while (true) { Thread.Sleep(7000); using (WebClient wc = new WebClient()) { var json = wc.DownloadString("http://35.165.103.236:80/unhandledclients"); unhandeledKlaten = JsonConvert.DeserializeObject <List <Klant> >(json); }/* * if (newKlant == null) * { * newKlant = new List<Klant>(); * newKlant = unhandeledKlaten; * } else if(unhandeledKlaten.Count != newKlant.Count){ * for (int i = 0; i < unhandeledKlaten.Count; i++) * { * if (unhandeledKlaten[i].Email !=) * } * }*/ newMarkers = new List <MarkerOptions>(); newMarkers.Clear(); for (int i = 0; i < unhandeledKlaten.Count; i++) { MarkerOptions marker = new MarkerOptions(); marker.SetPosition(new LatLng(unhandeledKlaten[i].Latitude, unhandeledKlaten[i].Longitude)); marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); marker.SetTitle("new"); //marker.SetTitle("" + newKlaten[i].Username); newMarkers.Add(marker); unhandeledKlaten[i].markerID = newMarkers.IndexOf(marker); } RunOnUiThread(() => tekenNieuweKlanten()); } }
// My location to be displayed at first launch from cached location which is fast async void GetLastCachedLocation() { try { if (CrossGeolocator.IsSupported && CrossGeolocator.Current.IsGeolocationEnabled) { var locator = CrossGeolocator.Current; var location = await locator.GetLastKnownLocationAsync(); if (location != null) { Map.Pins.Add(MyPin = new Pin() { Address = "", IsDraggable = false, Flat = true, Label = "Current Location", Type = PinType.SavedPin, IsVisible = true, Icon = BitmapDescriptorFactory.FromView(new BindingPinView("Me", Color.Transparent)), Position = new Position(location.Latitude, location.Longitude) }); Map.InitialCameraUpdate = (CameraUpdateFactory.NewPositionZoom(new Position(location.Latitude, location.Longitude), 12d)); await locator.StopListeningAsync(); } else { Handle_MyLocationButtonClicked(null, null); } } } catch (Exception) { } }
void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list) { OnCalculate?.Invoke(this, default(EventArgs)); Polylines.Clear(); var polyline = new Xamarin.Forms.GoogleMaps.Polyline(); foreach (var p in list) { polyline.Positions.Add(p); } Polylines.Add(polyline); MoveToRegion(MapSpan.FromCenterAndRadius(new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f))); var pin = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude), Label = "First", Address = "First", Tag = string.Empty, Icon = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_taxi.png") : BitmapDescriptorFactory.FromView(new Image() { Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25 }) }; Pins.Add(pin); var pin1 = new Xamarin.Forms.GoogleMaps.Pin { Type = PinType.Place, Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude), Label = "Last", Address = "Last", Tag = string.Empty }; Pins.Add(pin1); }
private void SetRouteOrderMarker(RoutePoint point, bool active) { if (point.Order.EndLatLng == null || this.routePointsMarkers.ContainsKey(point.Id)) { return; } MarkerOptions options = new MarkerOptions(); MarkerTag tag = new MarkerTag { PointId = point.Id, OrderId = point.OrderId, SalepointId = point.Order.SalepointId }; options.SetTitle(string.Concat(point.Order.DestinationCity, ", ", point.Order.DestinationAddress)); options.SetPosition(new LatLng(point.Order.EndLatLng.lat, point.Order.EndLatLng.lng)); BitmapDescriptor icon; if (active) { tag.Type = MarkerType.ActiveRoutePoint; icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.endpoint_marker); } else { tag.Type = MarkerType.PendingRoutePoint; icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.marker_bw); } options.SetIcon(icon); this.activity.RunOnUiThread(() => { Marker marker = this.map.AddMarker(options); marker.Tag = tag; this.routePointsMarkers.Add(point.Id, marker); }); }
private BitmapDescriptor GetCustomBitmapDescriptor(string text) { using (Paint paint = new Paint(PaintFlags.AntiAlias)) { using (Rect bounds = new Rect()) { using (Bitmap baseBitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Pin8)) { Bitmap resultBitmap = Bitmap.CreateBitmap(baseBitmap, 0, 0, baseBitmap.Width - 1, baseBitmap.Height - 1); Paint p = new Paint(); ColorFilter filter = new PorterDuffColorFilter(Android.Graphics.Color.ParseColor(text), PorterDuff.Mode.SrcAtop); p.SetColorFilter(filter); Canvas canvas = new Canvas(resultBitmap); canvas.DrawBitmap(resultBitmap, 0, 0, p); Bitmap scaledImage = Bitmap.CreateScaledBitmap(resultBitmap, 64, 64, false); BitmapDescriptor icon = BitmapDescriptorFactory.FromBitmap(scaledImage); resultBitmap.Recycle(); return(icon); } } } }
private void CreateNativePins(CustomMap customMap) { if (NativeMap != null) { NativeMap.Clear(); if (customMap.CustomPins?.Count > 0) { for (int i = 0; i < customMap.CustomPins.Count; i++) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(customMap.CustomPins[i].Location.Latitude, customMap.CustomPins[i].Location.Longitude)); marker.SetTitle(customMap.CustomPins[i].Title); marker.SetSnippet(customMap.CustomPins[i].Description); float[] hsv = new float[3]; Android.Graphics.Color.ColorToHSV(customMap.CustomPins[i].Color.ToAndroid(), hsv); var bitmap = BitmapDescriptorFactory.DefaultMarker(hsv[0]); marker.SetIcon(bitmap); NativeMap.AddMarker(marker); } } } }
protected override async void OnAppearing() { base.OnAppearing(); await Task.Delay(1000); // workaround for #30 [Android]Map.Pins.Add doesn't work when page OnAppearing var pin = new Pin() { //ID = "123", // optional, client app pin id for reference of this pin Type = PinType.Place, Label = "Tokyo SKYTREE", Address = "Sumida-ku, Tokyo, Japan", Position = new Position(35.71d, 139.81d), Icon = BitmapDescriptorFactory.FromView(new BindingPinView(pinDisplay.Text)) }; map.Pins.Add(pin); map.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMeters(5000))); pinDisplay.TextChanged += (sender, e) => { pin.Icon = BitmapDescriptorFactory.FromView(new BindingPinView(e.NewTextValue)); }; }
public void OnMapReady(GoogleMap googleMap) { gMap = googleMap; CameraUpdate mCameraUpdate1 = CameraUpdateFactory.NewLatLngZoom(sourcepos, 12); gMap.MoveCamera(mCameraUpdate1); mOptions[0] = new MarkerOptions() .SetPosition(sourcepos) .SetTitle(sourcestring) .SetSnippet("This is source") .Draggable(true) .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)); mOptions[1] = new MarkerOptions() .SetPosition(destpos) .SetTitle(deststring) .SetSnippet("This is destination") .Draggable(true); gMap.AddMarker(mOptions[0]); gMap.AddMarker(mOptions[1]); }
public void GetmyCurruntLocation(LatLng MLocation) { mainMap.MapType = GoogleMap.MapTypeNormal; _Latitude = MLocation.Latitude; _Longitude = MLocation.Longitude; LatLng latLng = new LatLng(_Latitude, _Longitude); CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latLng, 15); mainMap.MoveCamera(camera); //ICON Image MarkerOptions options = new MarkerOptions() .SetIcon(null) .SetPosition(latLng) .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.CarIcon)) .Draggable(true); mainMap.AddMarker(options); }
public void OnMapReady(GoogleMap googleMap) { _googleMap = googleMap; googleMap.MyLocationEnabled = true; googleMap.MyLocationButtonClick += LocationButtonClick; googleMap.UiSettings.MapToolbarEnabled = false; googleMap.UiSettings.ZoomControlsEnabled = true; googleMap.UiSettings.CompassEnabled = true; SetUpLocation(); //Set up current position/image BitmapDescriptor image = BitmapDescriptorFactory.FromResource(Resource.Drawable.bluedot); GroundOverlayOptions groundOverlayOptions = new GroundOverlayOptions() .Position(LocationToLatLong(_currentLocation), 10, 10) .InvokeImage(image); _myOverlay = _googleMap.AddGroundOverlay(groundOverlayOptions); MoveCamera(_currentLocation); }
public static void ReloadMapEventMarkers() { // Clear markers foreach (var marker in eventMarkers) { marker.Remove(); } eventMarkers.Clear(); // Get events from API var events = RequestSender.GetBriefEvents(); // Create markers foreach (var @event in events) { MarkerOptions marker = new MarkerOptions(); marker.SetPosition(new LatLng(@event.Latitude, @event.Longitude)); marker.SetTitle(@event.Name); marker.SetIcon(BitmapDescriptorFactory.FromBitmap(eventPin)); var mark = map.AddMarker(marker); eventMarkers.Add(mark); } }
public void OnLocationChanged(Location location) { if (_this.map != null) { if (_this.myMarker == null) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(new LatLng(location.Latitude, location.Longitude)); markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.player_01)); _this.myMarker = _this.map.AddMarker(markerOpt1); } else { if (!_this.clickMovement) { _this.myMarker.Position = new LatLng(location.Latitude, location.Longitude); } } } //Update region _this.playerRegion = _this.CalculateRegion((decimal)location.Latitude, (decimal)location.Longitude); }
private BitmapDescriptor GetIcon(string name) { switch (name) { case "wurm": return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_07)); case "bee": return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_09)); case "crab": return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_13)); case "rat": return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_03)); case "snake": return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_15)); default: return(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_07)); } }
private void MarkParks() { foreach (Park parque in Services.activeParks) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(new LatLng(parque.Latitude, parque.Longitude)); markerOpt1.SetTitle(parque.Id.ToString()); if (parque.StockingRate < 0.70) { markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); } else if (parque.StockingRate < 0.90) { markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)); } else { markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); } theMap.AddMarker(markerOpt1); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName.Equals("VisibleRegion") && !isDrawn) { NativeMap.Clear(); NativeMap.InfoWindowClick += OnInfoWindowClick; NativeMap.SetInfoWindowAdapter(this); foreach (var pin in customPins) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude)); marker.SetTitle(pin.Pin.Label); marker.SetSnippet(pin.Pin.Address); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin)); NativeMap.AddMarker(marker); } isDrawn = true; } }
async void ShowPOI(object sender, GoogleMap.MapLongClickEventArgs e) { LatLngBounds bounds = e.Point.GetBoundingBox(8000); // ~5mi pointsOfInterest.ForEach(m => m.Remove()); pointsOfInterest.Clear(); Geocoder geocoder = new Geocoder(this); var results = await geocoder.GetFromLocationNameAsync("Starbucks", 10, bounds.Southwest.Latitude, bounds.Southwest.Longitude, bounds.Northeast.Latitude, bounds.Northeast.Longitude); foreach (var result in results) { var markerOptions = new MarkerOptions() .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)) .SetPosition(new LatLng(result.Latitude, result.Longitude)) .SetTitle(result.FeatureName) .SetSnippet(GetAddress(result)); pointsOfInterest.Add(map.AddMarker(markerOptions)); } }
public void setMarkers() { _map.Clear(); if (spawnList != null) { for (int i = 0; i < spawnList.Count; i++) { LatLng tempPosition = new LatLng(spawnList[i]["spawnLatitude"], spawnList[i]["spawnLongitude"]); MarkerOptions options = new MarkerOptions(). SetPosition(tempPosition); _map.AddMarker(options); } } BitmapDescriptor icon = BitmapDescriptorFactory.FromAsset("15minuteman.bmp"); LatLng currentLatLng = new LatLng(currentLat, currentLong); MarkerOptions playerOption = new MarkerOptions() .SetPosition(currentLatLng) .SetIcon(icon) .SetTitle("Player"); _map.AddMarker(playerOption); }
public OverviewMapRenderer(Context context) : base(context) { Task.Run(async() => { var bikeSource = new FontImageSource { FontFamily = Fonts.SolidIcons, Glyph = FontAwesomeIcons.Bicycle, Color = Color.Black }; var stationSource = new FontImageSource { FontFamily = Fonts.SolidIcons, Glyph = FontAwesomeIcons.Home, Color = Color.Black }; var loader = new FontImageSourceHandler(); _bikeBitmapDescriptor = BitmapDescriptorFactory.FromBitmap(await loader.LoadImageAsync(bikeSource, context)); _stationBitmapDescriptor = BitmapDescriptorFactory.FromBitmap(await loader.LoadImageAsync(stationSource, context)); }); }
public BitmapDescriptor GetBitmapMarker(String text, Int32 size) { Int32 px = Util.DpToPx(size); using (Bitmap bitmap = Bitmap.CreateBitmap(px, px, Bitmap.Config.Argb8888)) { using (Canvas canvas = new Canvas(bitmap)) { using (Paint paint = new Paint()) { View markerView = LayoutInflater.From(_context).Inflate(Resource.Layout.marker_view_layout, null); markerView.LayoutParameters = new ViewGroup.LayoutParams(px, px); TextView textView = markerView.FindViewById <TextView>(Resource.Id.marker_count); textView.Text = text; canvas.DrawBitmap(CreateDrawableFromView(markerView), 0, 0, paint); } } return(BitmapDescriptorFactory.FromBitmap(bitmap)); } }
public void AddMarker(View view) { if (mBeijing == null && mShanghai == null) { // Uses a colored icon. mBeijing = hMap.AddMarker(new MarkerOptions().InvokePosition(Beijing).InvokeTitle("Beijing").Clusterable(true)); mShanghai = hMap.AddMarker(new MarkerOptions().InvokePosition(Shanghai) .InvokeAlpha(0.8f) .InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.badge_ph))); } if (null != mBeijing) { mBeijing.Title = "hello"; mBeijing.Snippet = "world"; mBeijing.Tag = "huaweimap"; mBeijing.Draggable = true; } if (null != mShanghai) { mShanghai.Title = "Hello"; mShanghai.Draggable = true; } }