private void UpdatePins() { var androidMapView = (MapView)Control; var formsMap = (CustomMap)Element; androidMapView.Map.Clear(); androidMapView.Map.MarkerClick += HandleMarkerClick; androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; UpdateTile(); var items = formsMap.Items; foreach (var item in items) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude)); markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name); markerWithIcon.SetSnippet(item.Details); try { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(GetPinIcon())); } catch (Exception) { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); } androidMapView.Map.AddMarker(markerWithIcon); } }
private void updateEpins() { var androidMapView = (MapView)Control; var formsMap = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element; androidMapView.Map.Clear(); androidMapView.Map.MarkerClick += HandleMarkerClick; androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; var items = formsMap.EPins; foreach (var item in items) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude)); markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name); markerWithIcon.SetSnippet(item.Details); try { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resources.GetIdentifier(item.ResourceNameImg, "drawable", Context.PackageName))); } catch (Exception) { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); } androidMapView.Map.AddMarker(markerWithIcon); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); GoogleMap map = mapFragment.Map; // TODO: move this to a listener instead map.MyLocationEnabled = true; var location = map.MyLocation; if (location == null) { LocationManager locationManager = (LocationManager)GetSystemService(Service.LocationService); Criteria criteria = new Criteria(); String provider = locationManager.GetBestProvider(criteria, true); location = locationManager.GetLastKnownLocation(provider); } if (location != null) { // TODO: get marker from Parse var latlong = new LatLng(location.Latitude, location.Longitude); map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(latlong, 16)); MarkerOptions markerOption = new MarkerOptions(); markerOption.SetPosition(latlong); markerOption.SetTitle("Ganteng"); markerOption.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.Icon)); map.AddMarker(markerOption); } }
private void UpdatePins() { var androidMapView = (MapView)Control; var formsMap = (ExtendedMap)Element; androidMapView.Map.Clear(); androidMapView.Map.MarkerClick += HandleMarkerClick; androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; if (formsMap.ItemsSource != null) { if (this.markers == null) { this.markers = new List <Marker> (); } var items = formsMap.ItemsSource.Cast <IMapModel> (); foreach (var item in items) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude)); markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name); markerWithIcon.SetSnippet(item.Details); markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); var addedMarker = androidMapView.Map.AddMarker(markerWithIcon); this.markers.Add(addedMarker); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); myAMapPage = e.NewElement as TencentMapPage; layout1 = new LinearLayout(this.Context); this.AddView(layout1); mapView = new MapView(this.Context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; LatLng SHANGHAI = new LatLng(31.238068, 121.501654); mapView.Map.SetCenter(SHANGHAI); 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(new BitmapDescriptor(bitmap)); markOption.InvokeTitle(pin.Name); markOption.InvokePosition(latLng1); var fix = mapView.Map.AddMarker(markOption); fix.ShowInfoWindow(); } mapView.Map.SetZoom(15); mapView.OnCreate(bundle); layout1.AddView(mapView); }
protected override Marker CreateNativeItem(Pin item) { MarkerOptions options = new MarkerOptions() .InvokePosition(item.Coordinate.ToNative()) .InvokeTitle(item.Title); if (item.Animate) { options.InvokeAnimateType(MarkerOptions.MarkerAnimateType.Grow); } options.Draggable(item.Draggable); options.Flat(!item.Enabled3D); BitmapDescriptor bitmap = item.Image?.ToNative(); if (null == bitmap) { throw new Exception("必须提供一个图标"); } options.InvokeIcon(bitmap); Marker marker = (Marker)NativeMap.Map.AddOverlay(options); item.NativeObject = marker; return(marker); }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var androidMapView = (MapView)Control; if (e.PropertyName.Equals("CenterOnPosition")) { CenterOnLocation(new LatLng(_customMap.CenterOnPosition.Latitude, _customMap.CenterOnPosition.Longitude), _customMap.CameraFocusYOffset); } if (e.PropertyName.Equals("VisibleRegion") && !_isDrawnDone) { androidMapView.Map.Clear(); androidMapView.Map.MarkerClick += HandleMarkerClick; androidMapView.Map.MapClick += HandleMapClick; androidMapView.Map.MyLocationEnabled = _customMap.IsShowingUser; //The footer overlays the zoom controls androidMapView.Map.UiSettings.ZoomControlsEnabled = false; var formsPins = _customMap.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; } }
private void AddMarker(int db, double lat, double lon, string info = "Keine Infos") { MarkerOptions opt = new MarkerOptions(); opt.SetPosition(new LatLng(lat, lon)); opt.SetTitle(db.ToString() + "db"); opt.SetSnippet(info); opt.InvokeIcon(GetIcon(GetColor(db))); _map.AddMarker(opt); }
public async Task SetupMapIfNeeded() { //if (_map == null) //{ if (_map != null) { var criteria = new Criteria { PowerRequirement = Power.Medium }; var bestProvider = locationManager.GetBestProvider(criteria, true); var location = locationManager.GetLastKnownLocation(bestProvider); System.Diagnostics.Debug.WriteLine("start timer maps loc " + location.Latitude); MarkerOptions markerOpt1 = new MarkerOptions(); VimyRidge = new LatLng(location.Latitude, location.Longitude); markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(VimyRidge); markerOpt1.SetTitle("Mi ubicación"); markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); _map.AddMarker(markerOpt1); List <Coord> requestCoord = await App.Database.GetAllCoordAsync(); foreach (Coord item in requestCoord) { System.Diagnostics.Debug.WriteLine("entra maps marker"); Passchendaele = new LatLng(Double.Parse(item.LATITUD), Double.Parse(item.LONGITUD)); markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(Passchendaele); markerOpt1.SetTitle(item.CMADDRESS); //markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); _map.AddMarker(markerOpt1); //MarkerOptions markerOpt2 = new MarkerOptions(); //markerOpt2.SetPosition(Passchendaele); //markerOpt2.SetTitle("Passchendaele"); //_map.AddMarker(markerOpt2); } // We create an instance of CameraUpdate, and move the map to it. 15 //actualizacion de la posicion de la camara if (ind == 0) { CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(VimyRidge, 10); _map.MoveCamera(cameraUpdate); ind = 1; } } //} }
private void updatePins() { var formsMap = (ExtendedMap)Element; var androidMapView = (Android.Gms.Maps.MapView)Control; androidMapView.Map.Clear(); androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; androidMapView.Map.MarkerClick += HandleMarkerClick; var items = formsMap.Pins; foreach (var item in items) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(item.Position.Latitude, item.Position.Longitude)); markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Label) ? "-" : item.Label); try { if (item.Label == "Driver Location") { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.car)); } else { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin)); } //markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin)); } catch (Exception) { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); } //markerWithIcon.Draggable(true); androidMapView.Map.AddMarker(markerWithIcon); } }
private Marker AddNewMarkerToMap(MapFragment mapFragment, LatLng position, BitmapDescriptor icon) { var marker = new MarkerOptions(); marker.SetPosition(position); marker.InvokeIcon(icon); var actualMarker = mapFragment.Map.AddMarker(marker); return(actualMarker); }
private void Addmarker(LatLng position, string title, string snippet) { var markerOptions = new MarkerOptions(); markerOptions.SetPosition(position); markerOptions.SetTitle(title); markerOptions.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); markerOptions.SetSnippet(snippet); _map.AddMarker(markerOptions); }
private void AddPin(ExtendedPin formsPin) { var androidMapView = (MapView)Control; 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.FromResource(GetResourceIdByName(formsPin.PinIcon))); } else { markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); } androidMapView.Map.AddMarker(markerWithIcon); }
// Animate Marker on the map between retrieving positions // Not working with MapBox for now private void AnimateMarkerOnMap(Icon icon, MarkerOptions markerToUpdate, LatLng newPosition, double?compassCourse, LatLng oldPosition) { markerToUpdate.InvokeIcon(icon); var evaluator = new LatLngEvaluator(); var valueAnimator = ValueAnimator.OfObject(evaluator, new LatLng(oldPosition.Latitude, oldPosition.Longitude), newPosition); valueAnimator.AddUpdateListener(new MarkerAnimatorAdapter(markerToUpdate)); valueAnimator.SetDuration(5000); valueAnimator.SetInterpolator(new Android.Views.Animations.LinearInterpolator()); valueAnimator.Start(); }
private void SetupMapIfNeeded() { try { if (_map == null) { _map = _mapFragment.Map; if (_map != null) { _map.Clear(); if (currentLocation != null) { MarkerOptions marker1 = new MarkerOptions(); marker1.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.A)); marker1.SetPosition(currentLocation); marker1.SetTitle("A"); _map.AddMarker(marker1); } MarkerOptions marker2 = new MarkerOptions(); marker2.SetPosition(new LatLng(lat, lng)); marker2.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.B)); marker2.SetTitle("B"); _map.AddMarker(marker2); if (Utils.Internet(ApplicationContext)) { if (currentLocation != null && currentLocation.Latitude != 0 && currentLocation.Longitude != 0 && lat != 0 && lng != 0) { var r = _map.AddPolyline(JSONRuta()); r.Color = Color.Red; } else { Toast.MakeText(this, "Se requiere conocer la ubicacion actual y destino para cargar la ruta", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Se requiere conexión a datos para cargar la ruta", ToastLength.Long).Show(); } if (currentLocation != null) { _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(currentLocation, 13)); } } } }catch (Exception ex) { throw ex; } }
private void addMarker(GoogleMap map, LatLng location) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(location); markerOpt1.SetTitle("My Location!"); var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan); markerOpt1.InvokeIcon(bmDescriptor); map.AddMarker(markerOpt1); }
public void OnMapReady(GoogleMap googleMap) { _map = googleMap; if (_map != null) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(new LatLng(ViewModel.Latitude, ViewModel.Longitude)); markerOpt1.SetTitle("Stadium"); markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); _map.AddMarker(markerOpt1); } }
private void updateMapFromDictionary(int index) { var map = mapFragment.Map; if (map != null) { map.Clear(); displayingIndex = index; updatePrevNextButtonVisibility(index); From fromPlace = fromNameDictionary [index]; LatLng fromLatLng = new LatLng(fromPlace.lat, fromPlace.lon); if (displayingIndex == 0) { txtMapDesc.Text = "Overview Map"; } else { txtMapDesc.Text = "Step " + index.ToString(); } MarkerOptions fromMarkerOpt = new MarkerOptions(); fromMarkerOpt.SetPosition(fromLatLng); fromMarkerOpt.SetTitle(fromPlace.name); fromMarkerOpt.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); var fromMarker = map.AddMarker(fromMarkerOpt); To toPlace = toNameDictionary [index]; LatLng toLatLng = new LatLng(toPlace.lat, toPlace.lon); MarkerOptions toMarkerOpt = new MarkerOptions(); toMarkerOpt.SetPosition(toLatLng); toMarkerOpt.SetTitle(toPlace.name); toMarkerOpt.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); var toMarker = map.AddMarker(toMarkerOpt); PolylineOptions polylineOptions = polylineDictionary [index]; var polyline = map.AddPolyline(polylineOptions); LatLngBounds bounds = findMapBounds(polylineOptions); CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 50); //map.AnimateCamera(cameraUpdate); map.MoveCamera(cameraUpdate); } }
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); } }
private void ZoomIntoCurrentLocation() { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(currentLocationLatLng); markerOpt1.SetTitle("My location"); markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); //MarkerOptions options = new MarkerOptions() //.SetPosition(currentLocationLatLng).SetTitle("My Location").SetSnippet("My current location"); //.SetIcon(BitmapDescriptorFactory.FromBitmap(GetCustomMyLocationMarkerView())); //.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue)); gMap.AddMarker(markerOpt1); gMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(currentLocationLatLng, 18)); }
private void addMarker(LatLng position, String title, String description) { Marker marker; MarkerOptions marker3Options = new MarkerOptions() .InvokePosition(position) .InvokeTitle(title) .InvokeSnippet(description); Bitmap bitmap1 = ResourceBitmapDescriptor.DrawableToBitmap(this, ContextCompat.GetDrawable(this, Resource.Drawable.markerblue)); marker3Options.InvokeIcon(BitmapDescriptorFactory.FromBitmap(bitmap1)); marker = hMap.AddMarker(marker3Options); hMap.MarkerDragStart += OnMarkerDragStart; hMap.MarkerDrag += OnMarkerDrag; hMap.MarkerDragEnd += OnMarkerDragEnd; }
public void OnLocationChanged(Location location) { LatLng here = new LatLng(location.Latitude, location.Longitude); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(here); builder.Zoom(16); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); _map.MoveCamera(cameraUpdate); List <Building> bldgs = Backend.GoogleCaller.BuildingProches(here.Longitude, here.Latitude); MarkerOptions marker1 = new MarkerOptions(); LatLng marker1Coords = new LatLng(bldgs[0].Lat, bldgs[0].Long); marker1.SetPosition(marker1Coords); marker1.SetTitle(bldgs[0].Name); _map.AddMarker(marker1); MarkerOptions marker2 = new MarkerOptions(); LatLng marker2Coords = new LatLng(bldgs[1].Lat, bldgs[1].Long); marker2.SetPosition(marker2Coords); marker2.SetTitle(bldgs[1].Name); _map.AddMarker(marker2); MarkerOptions marker3 = new MarkerOptions(); LatLng marker3Coords = new LatLng(bldgs[2].Lat, bldgs[2].Long); marker3.SetPosition(marker3Coords); marker3.SetTitle(bldgs[2].Name); _map.AddMarker(marker3); if (_currentPosMarker == null) { MarkerOptions curMarkerOps = new MarkerOptions(); curMarkerOps.SetPosition(here); curMarkerOps.SetTitle("You are here"); curMarkerOps.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure)); _currentPosMarker = _map.AddMarker(curMarkerOps); } _pDialog.Hide(); }
async Task FindNearestPlace() { var geoCoder = new Geocoder(this); var locations = await geoCoder.GetFromLocationAsync(Location_NewYork.Latitude, Location_NewYork.Longitude, 2); if (locations.Count > 0) { foreach (var location in locations) { MarkerOptions marker1 = new MarkerOptions(); marker1.SetPosition(new LatLng(location.Latitude, location.Longitude)); marker1.SetTitle(location.FeatureName); marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)); _map.AddMarker(marker1); } } }
async Task RunAddressQuery() { var geoCoder = new Geocoder(this); var addresses = await geoCoder.GetFromLocationNameAsync("Burbank Street", 50); if (addresses.Count > 0) { foreach (var address in addresses) { MarkerOptions marker1 = new MarkerOptions(); marker1.SetPosition(new LatLng(address.Latitude, address.Longitude)); marker1.SetTitle("Hollywood"); marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); _map.AddMarker(marker1); } } }
private void SetupMarkers() { var marker1 = new MarkerOptions(); marker1.SetPosition(AtlantaCoords); marker1.SetTitle("Atlanta"); marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)); var marker2 = new MarkerOptions(); marker2.SetPosition(VegasCoords); marker2.SetTitle("Vegas"); marker2.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed)); _map.AddMarker(marker1); _map.AddMarker(marker2); }
private void PopulateMap() { if (_map != null) { foreach (var tweet in viewModel.Tweets) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(new LatLng(tweet.GpsCoordinates.Latitude, tweet.GpsCoordinates.Longitude)); markerOpt1.SetTitle(tweet.Text); if (tweet.Text.ToLower().Contains("etech")) { markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); } _map.AddMarker(markerOpt1); } } }
internal void MarkersDemo(HuaweiMap hMap, Context context) { void MarkersDemo(HuaweiMap hMap, Android.Content.Context context) { hMap.Clear(); Marker marker1; MarkerOptions marker1Options = new MarkerOptions() .InvokePosition(new LatLng(41.0083, 28.9784)) .InvokeTitle("Marker Title #1") .InvokeSnippet("Marker Desc #1"); marker1 = hMap.AddMarker(marker1Options); Marker marker2; MarkerOptions marker2Options = new MarkerOptions() .InvokePosition(new LatLng(41.022231, 29.008118)) .InvokeTitle("Marker Title #2") .InvokeSnippet("Marker Desc #2"); marker2 = hMap.AddMarker(marker2Options); Marker marker3; MarkerOptions marker3Options = new MarkerOptions() .InvokePosition(new LatLng(41.005784, 28.997364)) .InvokeTitle("Marker Title #3") .InvokeSnippet("Marker Desc #3"); Bitmap bitmap1 = ResourceBitmapDescriptor.DrawableToBitmap(context, ContextCompat.GetDrawable(context, Resource.Drawable.markerblue)); marker3Options.InvokeIcon(BitmapDescriptorFactory.FromBitmap(bitmap1)); marker3 = hMap.AddMarker(marker3Options); Marker marker4; MarkerOptions marker4Options = new MarkerOptions() .InvokePosition(new LatLng(41.028435, 28.988186)) .InvokeTitle("Marker Title #4") .InvokeSnippet("Marker Desc #4") .Anchor(0.9F, 0.9F) .Draggable(true); Bitmap bitmap2 = ResourceBitmapDescriptor.DrawableToBitmap(context, ContextCompat.GetDrawable(context, Resource.Drawable.marker)); marker4Options.InvokeIcon(BitmapDescriptorFactory.FromBitmap(bitmap2)); marker4 = hMap.AddMarker(marker4Options); } }
private void UpdatePins() { var androidMapView = (MapView)Control; var formsMap = (ExtendedMap)Element; androidMapView.Map.Clear(); androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser; if (formsMap.ItemsSource != null) { if (this.markers == null) { this.markers = new List <Marker> (); } var items = formsMap.ItemsSource.Cast <IMapModel> (); foreach (var item in items) { var markerWithIcon = new MarkerOptions(); markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude)); markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name); markerWithIcon.SetSnippet(item.Details); markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker()); var addedMarker = androidMapView.Map.AddMarker(markerWithIcon); this.markers.Add(addedMarker); } var central = GeoHelper.GetCentralPosition(items.Select(i => i.Location)); var radius = GeoHelper.GetRadius(central, items.Select(i => i.Location), true); this.MoveToRegion( MapSpan.FromCenterAndRadius( central, Distance.FromMeters(radius) ), false ); } }
private void SetupMapIfNeeded() { if (_map == null) { if (_map != null) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(getCurrentPosition()); markerOpt1.SetTitle("Current Position"); markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); _map.AddMarker(markerOpt1); // We create an instance of CameraUpdate, and move the map to it. CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(getCurrentPosition(), 15); _map.MoveCamera(cameraUpdate); } } }
private void SetupMapIfNeeded() { if (_map == null) { _map = _mapFragment.Map; if (_map != null) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(CacheManager.AverisCoordinate); markerOpt1.SetTitle("Averis Sdn Bhd"); markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan)); _map.AddMarker(markerOpt1); _map.MarkerClick += MarkerClick; // We create an instance of CameraUpdate, and move the map to it. CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(CacheManager.AverisCoordinate, 16); _map.MoveCamera(cameraUpdate); } } }