private void NativeMapOnMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (e?.Location == null) { return; } if (Element is ResearchMap researchMap) { if (researchMap.CameraFollowsUser) { var newLat = e.Location.Latitude; var newLong = e.Location.Longitude; var bearing = e.Location.Bearing; var cameraPositionBuilder = CameraPosition.InvokeBuilder(); cameraPositionBuilder.Target(new LatLng(newLat, newLong)); cameraPositionBuilder.Bearing(bearing); cameraPositionBuilder.Zoom(researchMap.CameraZoom); var cameraPosition = cameraPositionBuilder.Build(); var cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); NativeMap.AnimateCamera(cameraUpdate); } } // Console.WriteLine($"ResearchMapRenderer: Lat={location.Latitude}, Long={location.Longitude}, Alt={location.Altitude}, Spd={location.Speed}, Acc={location.Accuracy}, Hdg={location.Bearing}"); }
/// <summary> /// Sets the user position once. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">E event.</param> protected void SetUserPositionOnce(object sender, GoogleMap.MyLocationChangeEventArgs e) { this.Map.MyLocationChange -= this.SetUserPositionOnce; var latlng = new LatLng(e.Location.Latitude, e.Location.Longitude); this.Map.MoveCamera(CameraUpdateFactory.NewLatLng(latlng)); }
private void _map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { CurrentLocation = new LatLng(e.Location.Latitude, e.Location.Longitude); if (CurrentLocation.Longitude == 0 || CurrentLocation.Latitude == 0) { return; } CameraUpdate cameraUpdate1 = CameraUpdateFactory.NewLatLngZoom(CurrentLocation, 17); _map.MoveCamera(cameraUpdate1); if (_map.MyLocationEnabled) { UserLocation = CurrentLocation; _map.MyLocationEnabled = false; MarkerOptions marker = new MarkerOptions(); marker.SetPosition(UserLocation); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Mipmap.ic_user_location)); _map.AddMarker(marker); GetAddressByLocation(); } }
private void Map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { mMap.MyLocationChange -= Map_MyLocationChange; var location = new GeoLocation(e.Location.Latitude, e.Location.Longitude, e.Location.Altitude); //MoveToLocation(location); vm.OnMyLocationChanged(location); }
private void GoogleMap_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (!m_InitLocation) { mapToMyLocation(); m_InitLocation = true; } }
void OnMyLocationChanged(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (RequestedShowUserLocation) { InternalMoveToRegion(MapRegion.FromPositions(new List <Position> { new Position(e.Location.Latitude, e.Location.Longitude) }), true, 16); ResetShowUserLocation(); } }
/// <summary> /// Handles the LocationChange event of sender. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="GoogleMap.MyLocationChangeEventArgs"/> with arguments of the event.</param> private void OnLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { // If accuracy is too high if (e.Location.HasAccuracy && (e.Location.Accuracy >= 50)) { return; } // Report the new map coordinates ((MapEx)this.Element).UserPosition = new Position(e.Location.Latitude, e.Location.Longitude); }
public void LocationChanged(object sender, GoogleMap.MyLocationChangeEventArgs eventArgs) { var point = new Point { Lat = eventArgs.Location.Latitude, Lng = eventArgs.Location.Longitude }; ViewModel.LocationChanged(point); _locationProvider.CurrentLocation = point; }
/// <summary> /// When the location of the user changed /// </summary> /// <param name="sender">Event Sender</param> /// <param name="e">Event Arguments</param> private void OnUserLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (e.Location == null || this.FormsMap == null || this.FormsMap.UserLocationChangedCommand == null) { return; } var newPosition = new Position(e.Location.Latitude, e.Location.Longitude); this.MapFunctions.RaiseUserLocationChanged(newPosition); }
void HandleMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { Log.Debug(TAG, "New location detected"); _myCurrentLocation = e.Location; if (!_wasZoomedToCurrentLocation) { ZoomToMyLocationAndAlarms(); } _wasZoomedToCurrentLocation = true; }
/// <summary> /// When the location of the user changed /// </summary> /// <param name="sender">Event Sender</param> /// <param name="e">Event Arguments</param> private void OnUserLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (e.Location == null || this.FormsMap == null || this.FormsMap.UserLocationChangedCommand == null) { return; } var newPosition = new Position(e.Location.Latitude, e.Location.Longitude); if (this.FormsMap.UserLocationChangedCommand.CanExecute(newPosition)) { this.FormsMap.UserLocationChangedCommand.Execute(newPosition); } }
private void LocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (IsMoving) { return; } else { IsMoving = true; } CameraPosition cameraPosition = new CameraPosition(target: new LatLng(e.Location.Latitude, e.Location.Longitude), zoom: 20f, tilt: 45f, bearing: e.Location.Bearing); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); NativeMap.AnimateCamera(cameraUpdate); }
private void GMap_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { if (progDialog != null) { progDialog.Dismiss(); progDialog = null; } if (alreadyCentered) { return; } alreadyCentered = true; GMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(e.Location.Latitude, e.Location.Longitude), 18f)); }
private void GoogleMap_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { GoogleMap googleMap = sender as GoogleMap; currentLocation = new LatLng(e.Location.Latitude, e.Location.Longitude); if (!isFirst) { googleMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(currentLocation, googleMap.CameraPosition.Zoom)); } else { googleMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(currentLocation, 16.00f)); isFirst = false; } CheckTollRoad(); }
private void MapOnLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { Location loc = e.Location; if (_GoogleMap.MyLocationEnabled) { if (_Mappa.Raggio > 0) { _GoogleMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(loc.Latitude, loc.Longitude), zoomLevel(_Mappa.Raggio))); } else { _GoogleMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(loc.Latitude, loc.Longitude), zoomLevel(10))); } } _GoogleMap.MyLocationChange -= MapOnLocationChange; }
private void Map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { var location = new GeoLocation(e.Location.Latitude, e.Location.Longitude, e.Location.Altitude); if (firstLocationChange) { MoveToLocation(location, 13); firstLocationChange = false; } else { MoveToLocation(location); } vm.OnMyLocationChanged(location); // check if we're near a bridge for (var i = 0; i < bridgeMarkers.Count; i++) { Android.Locations.Location markerLocation = new Android.Locations.Location("bridge"); markerLocation.Latitude = bridgeMarkers[i].Position.Latitude; markerLocation.Longitude = bridgeMarkers[i].Position.Longitude; if (e.Location.DistanceTo(markerLocation) < 100) { if (!bridgeMarkers[i].IsInfoWindowShown) { bridgeMarkers[i].Title = "WARNING"; bridgeMarkers[i].Snippet = "Approaching Low Clearance Bridge"; bridgeMarkers[i].ShowInfoWindow(); //vm.OnMyLocationNearBridge(new GeoLocation(marker.Position.Latitude, marker.Position.Longitude)); } } else { if (bridgeMarkers[i].IsInfoWindowShown) { bridgeMarkers[i].HideInfoWindow(); } } } }
private void Map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { latLngSource = new LatLng(e.Location.Latitude, e.Location.Longitude); }
private void OnMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { currentLocation = e.Location; }
void map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { latLngUser.Latitude = e.Location.Latitude; latLngUser.Longitude = e.Location.Longitude; }
private void MapOnMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { throw new NotImplementedException(); }
private void GMap_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { StopDialog(); GMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(e.Location.Latitude, e.Location.Longitude), 18f)); }
void Map_MyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e) { map.MyLocationChange -= Map_MyLocationChange; LatLng latLong = new LatLng(e.Location.Latitude, e.Location.Longitude); Lat = e.Location.Latitude; Lon = e.Location.Longitude; Toast.MakeText(this, "Current location is red point! Coordinates: " + Lat + " " + Lon, ToastLength.Long).Show(); PolylineOptions polylineOptions = new PolylineOptions(); string text = Intent.GetStringExtra("user") ?? "Data not available"; int bicId = Intent.GetIntExtra("bicycleid", 1); var user = JsonConvert.DeserializeObject <List <User> >(text); RestClient client = new RestClient("http://marichely.me:8099/"); RestRequest request = new RestRequest("bicycle/location", Method.GET); request.RequestFormat = DataFormat.Json; request.AddHeader("userapikey", user[0].ApiKey); request.AddParameter("bicycleid", bicId, ParameterType.QueryString); IRestResponse odgovor = client.Execute(request); if ((int)odgovor.StatusCode == 200) { locObj = JsonConvert.DeserializeObject <List <Data_classes.Location> >(odgovor.Content); } foreach (Data_classes.Location item in locObj) { var lsa = double.TryParse(item.Latitude, out later); var lar = double.TryParse(item.Longitude, out longers); if (lsa == true && lar == true) { polylineOptions.Add(new LatLng(later, longers)); latLng2 = new LatLng(later, longers); GetRequestUrl(latLong, latLng2); } } polylineOptions.Add(latLong); polylineOptions.InvokeColor(Color.Blue); map.AddPolyline(polylineOptions); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(latLong); builder.Zoom(16); builder.Tilt(65); CameraPosition cameraPosition = builder.Build(); MarkerOptions markerOpt = new MarkerOptions(); markerOpt.SetPosition(latLong); foreach (var item in polylineOptions.Points) { MarkerOptions markerOptions2 = new MarkerOptions(); markerOptions2.SetPosition(item); BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure); markerOptions2.SetIcon(bitmapDescriptor); map.AddMarker(markerOptions2); } map.AddMarker(markerOpt); map.SetInfoWindowAdapter(this); map.MyLocationEnabled = true; map.UiSettings.MapToolbarEnabled = true; map.UiSettings.MyLocationButtonEnabled = true; map.UiSettings.ZoomControlsEnabled = true; map.UiSettings.ZoomGesturesEnabled = true; map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition)); map.TrafficEnabled = true; }