public async void getCurrentLoc(GoogleMap googleMap) { Console.WriteLine("Test - CurrentLoc"); try { var request = new GeolocationRequest(GeolocationAccuracy.Medium); var location = await Geolocation.GetLocationAsync(request); if (location != null) { Console.WriteLine($"current Loc - Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}"); MarkerOptions curLoc = new MarkerOptions(); curLoc.SetPosition(new LatLng(location.Latitude, location.Longitude)); curLoc.SetTitle("You are here"); curLoc.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)); googleMap.AddMarker(curLoc); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(new LatLng(location.Latitude, location.Longitude)); builder.Zoom(18); builder.Bearing(155); builder.Tilt(65); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); googleMap.MoveCamera(cameraUpdate); } else { getLastLocation(googleMap); } } catch (FeatureNotSupportedException fnsEx) { // Handle not supported on device exception Toast.MakeText(this, "Feature Not Supported", ToastLength.Short); } catch (FeatureNotEnabledException fneEx) { // Handle not enabled on device exception Toast.MakeText(this, "Feature Not Enabled", ToastLength.Short); } catch (PermissionException pEx) { // Handle permission exception Toast.MakeText(this, "Needs more permission", ToastLength.Short); } catch (Exception ex) { getLastLocation(googleMap); } }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (pin.ClassId == "Cable") { opc = 1; //marker.SetAlpha (1); } if (pin.ClassId == "Remote") { opc = 2; //marker.SetAlpha(2); } if (pin.ClassId == "Tasa") { opc = 3; //marker.SetAlpha(3); } if (pin.StyleId == "ConCitaOtroDia") { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin2azul)); } if (pin.StyleId == "SinCita") { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin2rojo)); } if (pin.StyleId == "ConCitaHoy") { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin2verde)); } return(marker); }
void map_MarkerDragEnd(object sender, GoogleMap.MarkerDragEndEventArgs e) { map.Clear(); latLngMarker.Latitude = e.Marker.Position.Latitude; latLngMarker.Longitude = e.Marker.Position.Longitude; distance = Location.CalculateDistance(latLngMarker.Latitude, latLngMarker.Longitude, latLngUser.Latitude, latLngUser.Longitude, DistanceUnits.Kilometers); if (distance <= 1) { marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); circle.InvokeFillColor(Android.Graphics.Color.Green); marker.SetPosition(latLngMarker); circle.InvokeCenter(latLngMarker); map.AddMarker(marker); map.AddCircle(circle); async void SendMail() { List <string> to = new List <string>(); var message = new EmailMessage { Subject = "Point", Body = "User coordinates - " + latLngUser.Latitude + " " + latLngUser.Longitude + "\n" + "Marker coordinates - " + marker.Position.Latitude + " " + marker.Position.Longitude, To = to }; await Email.ComposeAsync(message); } SendMail(); } else { marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); circle.InvokeFillColor(0X66FF0000); marker.SetPosition(latLngMarker); circle.InvokeCenter(latLngMarker); map.AddMarker(marker); map.AddCircle(circle); } }
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); }
public static MarkerOptions Make(Pin poi, int maxWidthImage, string imageMarkerPath) { var marker = new MarkerOptions(); marker.Anchor(0.5f, 0.5f); marker.SetPosition(new LatLng(poi.Position.Latitude, poi.Position.Longitude)); BitmapDescriptor pic = !string.IsNullOrEmpty(imageMarkerPath) ? getBitmap(imageMarkerPath, maxWidthImage) : BitmapDescriptorFactory.FromResource(Resource.Drawable.place_unknown); marker.SetIcon(pic); return(marker); }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); //if (pin.BindingContext is Models.CompanyModel com) // marker.InvokeZIndex(com.id); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.marker)); return(marker); }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); marker.SetIcon(pin.Label == "Available" ? BitmapDescriptorFactory.FromResource(Resource.Drawable.taxi_available) : BitmapDescriptorFactory.FromResource(Resource.Drawable.taxi_unavailable)); return(marker); }
private void AddMarker(MapPin pin) { using (var op = new MarkerOptions()) { op.SetTitle(pin.Label); op.SetPosition(pin.Position.ToLatLng()); op.SetIcon(BitmapDescriptorFactory.DefaultMarker(pin.Color.ToAndroidMarkerHue())); var marker = NativeMap.AddMarker(op); pin.Id = marker.Id; Markers.Add(pin, marker); } }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); var customPin = (CustomPin)pin;// customPins.Where(x => x.Position.Latitude == pin.Position.Latitude && x.Position.Longitude == pin.Position.Longitude).FirstOrDefault(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (customPin.IsSelected) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinnero)); } else { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinblu)); } return(marker); }
//-------------------------------------------------------------------- // SUPPORT METHODS FOR EXTERNAL METHODS //-------------------------------------------------------------------- private void AddBridge(GeoLocation location) { // add marker var markerOptions = new MarkerOptions(); markerOptions.SetPosition(new LatLng(location.Latitude, location.Longitude)); markerOptions.SetTitle(location.Locality); markerOptions.SetIcon(BitmapDescriptorFactory.FromAsset("bridge32.png")); Marker marker = map.AddMarker(markerOptions); bridgeMarkers.Add(marker); }
private void LoadPositionMarker() { MarkerOptions marker = new MarkerOptions(); marker.SetPosition(CurrentPosition); marker.SetIcon(GetCustomBitmapDescriptor("", Resource.Mipmap.UserPin)); MarkerOptionsArray.Add(marker); _googleMap.AddMarker(marker); }
private void SetMyMarker() {
 RunOnUiThread(() => { LatLng myPos = new LatLng( Convert.ToDouble(_myPosition.Latitude/*, (CultureInfo.InvariantCulture)*/), Convert.ToDouble(_myPosition.Longitude/*, (CultureInfo.InvariantCulture)*/));
 _myMarker = new MarkerOptions(); _myMarker.SetPosition(myPos); _userMarker = BitmapDescriptorFactory.FromResource(Resource.Drawable.myMarker); _myMarker.SetIcon(_userMarker); _map.AddMarker(_myMarker);
 if(//!launched 
 String.IsNullOrWhiteSpace(HomeAddressActivity.FullAddressTemp) && String.IsNullOrEmpty(Lat) && String.IsNullOrEmpty(Lng))
 {
 CenterPositionBn_Click(null, null);
 _launched = true;
 } }); }

 // Method to detect if GPS is enabled
 public bool IsGeolocationEnabled()
 {
 return CrossGeolocator.Current.IsGeolocationEnabled;
 }
 async Task<bool> CheckLocPermission()
 {
 PermissionStatus locationStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);

 if (locationStatus != PermissionStatus.Granted)
 {
 var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });
 locationStatus = results[Permission.Location];
 if(!_userDeclinedPermission)
 request_runtime_permissions();
 return false;
 }

 return true;
 }

 private const int requestPermissionCode = 1000;
 void request_runtime_permissions()
 {
 if (Build.VERSION.SdkInt >= Build.VERSION_CODES.M)
 if (
 CheckSelfPermission(Manifest.Permission.AccessFineLocation) != Android.Content.PM.Permission.Granted
 || CheckSelfPermission(Manifest.Permission.AccessCoarseLocation) != Android.Content.PM.Permission.Granted
 || CheckSelfPermission(Manifest.Permission.AccessMockLocation) != Android.Content.PM.Permission.Granted)
 {
 ActivityCompat.RequestPermissions(this, new String[]
 {
 Manifest.Permission.AccessFineLocation,
 Manifest.Permission.AccessCoarseLocation,
 Manifest.Permission.AccessMockLocation,
 }, requestPermissionCode);
 }
 else
 {
 ActivityCompat.RequestPermissions(this, new String[]
 {
 Manifest.Permission.AccessFineLocation,
 Manifest.Permission.AccessCoarseLocation,
 Manifest.Permission.AccessMockLocation,
 }, requestPermissionCode);
 }
 }
 bool _shown = false;
public void OnLocationChanged(Android.Locations.Location location) { LatLng newloc = new LatLng(location.Latitude, location.Longitude); MarkerOptions m = new MarkerOptions(); m.SetPosition(newloc); int id0 = (int)typeof(Resource.Drawable).GetField("locationpoint").GetValue(null); BitmapDescriptor bmd0 = BitmapDescriptorFactory.FromResource(id0); m.SetIcon(bmd0); googleMap.AddMarker(m); }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetSnippet(pin.Address); string[] pinColor = pin.Label.Split('/'); if (!(String.IsNullOrEmpty(pinColor[1]))) { switch (pinColor[1]) { case "RED": marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); break; case "BLUE": marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)); break; case "YELLOW": marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)); break; case "ORANGE": marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueOrange)); break; case "GREEN": marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); break; } } marker.SetTitle(pinColor[0]); return(marker); }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (pin.Label.Contains("SECTOR 1")) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora1)); } else if (pin.Label.Contains("SECTOR 2")) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora2)); } else if (pin.Label.Contains("SECTOR 3")) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora3)); } else if (pin.Label.Contains("SECTOR 4")) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora4)); } else if (pin.Label.Contains("SECTOR 5")) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora5)); } else { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.corregidora)); } return(marker); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { try { base.OnElementPropertyChanged(sender, e); // if (!isDrawn) { //NativeMap.Clear(); NativeMap.InfoWindowClick += OnInfoWindowClick; var polylineOptions = new PolylineOptions(); polylineOptions.InvokeColor(0x66FF0000); foreach (var pin in ((CustomMap)Element).CustomPins) { BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.pin); 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(icon); if (pin.Id != "1") { MoveAble_Marker = NativeMap.AddMarker(marker); } else { NativeMap.AddMarker(marker); } } // foreach (var position in ((CustomMap)Element).RouteCoordinates) { polylineOptions.Add(new LatLng(position.Latitude, position.Longitude)); } NativeMap.AddPolyline(polylineOptions); isDrawn = true; //Device.StartTimer(TimeSpan.FromSeconds(10), () => //{ // update(); // return true; //}); } } catch { } }
protected override MarkerOptions CreateMarker(Pin pin) { CustomPin customPin = (CustomPin)pin; var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); if (customPin.Icon == "driver") { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin)); } return(marker); }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (((CustomPin)pin).MarkerType == "Marcador") { marker.SetIcon(BitmapDescriptorFactory.DefaultMarker()); } else if (((CustomPin)pin).MarkerType == "Adopcion") { marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(hue: BitmapDescriptorFactory.HueViolet)); } else { marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(hue: BitmapDescriptorFactory.HueGreen)); } return(marker); }
public static MarkerOptions CreateMarker(LatLng position, string title, string snippet, float color) { MarkerOptions mo = new MarkerOptions(); mo.SetPosition(position); // Nombre del Establecimiento mo.SetTitle(title); // Direccion del Establecimiento mo.SetSnippet(snippet); mo.SetIcon(BitmapDescriptorFactory.DefaultMarker(color)); return(mo); }
protected override void OnBeforeClusterRendered(ICluster cluster, MarkerOptions options) { NativeBitmapDescriptor icon; if (map.ClusterOptions.RendererCallback != null) { var descriptorFromCallback = map.ClusterOptions.RendererCallback(map.ClusterOptions.EnableBuckets ? GetClusterText(cluster) : cluster.Size.ToString()); icon = GetIcon(cluster, descriptorFromCallback); options.SetIcon(icon); } else if (map.ClusterOptions.RendererImage != null) { icon = GetIcon(cluster, map.ClusterOptions.RendererImage); options.SetIcon(icon); } else { base.OnBeforeClusterRendered(cluster, options); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName.Equals("VisibleRegion")) { map.Clear(); 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); //if (pin.Pin.Type == PinType.Place) //{ //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_branches)); //} if (pin.Type.ToString() == pin.branchId) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_branches)); } else if (pin.Type.ToString() == pin.kioskId) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_kiosks)); } else if (pin.Type.ToString() == pin.partnerId) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_partner)); } map.AddMarker(marker); } isDrawn = true; } }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SearchJourney); #region setup map markers currentLocation = new MarkerOptions(); currentLocation.SetTitle("Current Position"); currentLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue)); currentLocation.SetPosition(getCurrentPosition()); currentLocation.Visible(false); fromLocation = new MarkerOptions(); fromLocation.SetTitle("From Here"); fromLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); fromLocation.SetPosition(getCurrentPosition()); fromLocation.Visible(false); toLocation = new MarkerOptions(); toLocation.SetTitle("To Here"); toLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); toLocation.SetPosition(getCurrentPosition()); toLocation.Visible(false); fromCircleOp = new CircleOptions(); fromCircleOp.InvokeCenter(getCurrentPosition()); fromCircleOp.InvokeRadius(1000); fromCircleOp.InvokeFillColor(0X66FF0000); fromCircleOp.InvokeStrokeColor(0X66FF0000); fromCircleOp.InvokeStrokeWidth(0); fromCircleOp.Visible(false); toCircleOp = new CircleOptions(); toCircleOp.InvokeCenter(getCurrentPosition()); toCircleOp.InvokeRadius(1000); toCircleOp.InvokeFillColor(Color.Green); toCircleOp.InvokeStrokeColor(Color.Green); toCircleOp.InvokeStrokeWidth(0); toCircleOp.Visible(false); #endregion // Create your application here InitMapFragment(); SetupCurrentLocationButton(); SetupSearchButton(); SetupSetFromButton(); SetupSetToButton(); SetupForm(); }
public static void LocationUpdated(List <Excursionist> Excursionisti) { if (AfisareTipGrid != null) { context.RunOnUiThread(() => { AfisareTipGrid.Adapter = new Organizator_Trip_VizualizatreExcursionisti_Adapter(context, Excursionisti.ToArray()); LocationManager lm = (LocationManager)context.GetSystemService(LocationService); Location l = lm.GetLastKnownLocation(LocationManager.NetworkProvider); LatLng location = new LatLng(double.Parse(l.Latitude.ToString()), double.Parse(l.Longitude.ToString())); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(location); builder.Zoom(18); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); MapFragment mapFrag = MapFragment.NewInstance(); mapFrag = (MapFragment)((FragmentActivity)context).FragmentManager.FindFragmentById(Resource.Id.map); if (mapFrag != null) { GoogleMap map = mapFrag.Map; map.Clear(); List <MarkerOptions> Markers = new List <MarkerOptions>(); foreach (Excursionist e in Excursionisti.ToList()) { Bitmap UserPhoto = ((BitmapDrawable)e.Photo).Bitmap; MarkerOptions UserMarker = new MarkerOptions(); try { string Latitude = e.Pozitie.Split(',')[0]; string Longitude = e.Pozitie.Split(',')[1]; UserMarker.SetPosition(new LatLng(double.Parse(Latitude.Replace('.', ',')), double.Parse(Longitude.Replace('.', ',')))); UserMarker.SetIcon(BitmapDescriptorFactory.FromBitmap(UserPhoto)); UserMarker.SetTitle(e.Nume + " " + e.Prenume); map.AddMarker(UserMarker); } catch { } } map.MapType = GoogleMap.MapTypeNormal; map.MoveCamera(cameraUpdate); } }); } }
private void AddRaidMarker(Raid r) { var mOps = new MarkerOptions(); mOps.SetPosition(r.Location); mOps.SetIcon(BitmapDescriptorFactory.FromBitmap(GetRaidMarker(r))); mOps.Anchor(0.5f, 0.5f); var marker = map.AddMarker(mOps); marker.Tag = $"raid:{r.id}"; r.RaidMarker = marker; raidsVisible.Add(r); }
private void Spawn() { MarkerOptions markOpt; int spawnCount = RandomNumber(minCount, maxCount); for (int i = 0; i < spawnCount; i++) { markOpt = new MarkerOptions(); markOpt.SetPosition(getLocation(latitude, longitude, radius)); markOpt.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.monster_07)); Marker tempM = map.AddMarker(markOpt); markers.Add(tempM); } }
/// <summary> /// This function creates a Google Maps marker for the Xamarin Map. /// </summary> /// <param name="pin"></param> /// <returns></returns> protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); /*Since we need extra details when creating the callout, we store the current pin temporarily for those details.*/ tempPin = (CustomPin)pin; marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.MapPin)); return(marker); }
private async Task AddPinAsync(IMapPin pin) { if (_markers.ContainsKey(pin)) { return; } var mapPin = new MarkerOptions(); mapPin.InvokeZIndex(pin.ZIndex); if (!string.IsNullOrWhiteSpace(pin.Title)) { mapPin.SetTitle(pin.Title); } if (!string.IsNullOrWhiteSpace(pin.Snippet)) { mapPin.SetSnippet(pin.Snippet); } mapPin.SetPosition(new LatLng(pin.Location.Latitude, pin.Location.Longitude)); if (pin.Image != null) { mapPin.Anchor((float)pin.Anchor.X, (float)pin.Anchor.Y); } var selected = pin.EqualsSafe(Map.SelectedItem); mapPin.SetIcon(await DeterminMarkerImage(pin, selected)); if (_markers.ContainsKey(pin)) { return; } var markerView = _googleMap.AddMarker(mapPin); _markers.Add(pin, markerView); if (selected && Map.CanShowCalloutOnTap) { markerView.ShowInfoWindow(); } else { markerView.HideInfoWindow(); } }
protected override MarkerOptions CreateMarker(Pin pin) { var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); if (((CustomPin)pin).PinType == CustomPin.CustomType.Park) { marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.bike_park)); } return(marker); }
protected override MarkerOptions CreateMarker(Pin pin) { CustomPin customPin = GetCustomPin(pin); var marker = new MarkerOptions(); marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude)); marker.SetTitle(pin.Label); marker.SetSnippet(pin.Address); marker.SetIcon(BitmapDescriptorFactory.FromAsset($"m{customPin.NumMoments}.png")); //marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueMagenta));//.FromResource(Resource.Drawable.pin)); return(marker); }
public void OnLocationChanged(Android.Locations.Location location) { MarkerOptions currentPos = new MarkerOptions(); currentPos.SetPosition(new LatLng(location.Latitude, location.Longitude)); currentPos.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)); currentPos.SetTitle("Your Position"); _currentLocationMarker?.Remove(); if (MMap != null) { _currentLocationMarker = MMap.AddMarker(currentPos); } foreach (var marker in _markerList) { if (Location.CalculateDistance(new Location(location.Latitude, location.Longitude), new Location(marker.Lat, marker.Lon), DistanceUnits.Kilometers) < marker.Dist) { if (!marker.Availability) { try { MailAddress from = new MailAddress("*****@*****.**", "XamarinApp"); MailAddress to = new MailAddress(user_email); MailMessage m = new MailMessage(from, to) { Subject = "Location Tracking", Body = $"<h2>You are near place named: {marker.Title}<h2>" + $"Your latitude is {location.Latitude}, your longitude is {location.Longitude}", IsBodyHtml = true }; var smtp = new SmtpClient("smtp.gmail.com") { Credentials = new NetworkCredential("oop.exam.xam", ""), EnableSsl = true }; // password is not pulic. smtp.Send(m); marker.Availability = true; } catch { // ignored } } } else if (marker.Availability) { marker.Availability = false; } } }