コード例 #1
0
		/// <summary>
		/// Handles the <see cref="E:PositionChanged" /> event.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="e">The <see cref="PositionEventArgs"/> instance containing the event data.</param>
		private void OnPositionChanged(object sender, PositionEventArgs e)
		{
			try {
				object position = new { 
					Latitude = e.Position.Latitude, 
					Longitude = e.Position.Longitude, 
					Timestamp = e.Position.Timestamp,
					Accuracy = e.Position.Accuracy,
					Speed = e.Position.Speed,
					Altitude = e.Position.Altitude
				};
				JObject jsonObject = JObject.FromObject(position);

				//TuGrua.App.io.Emit ("SetPositionCrane", jsonObject);

			} catch (Exception ex) {
				Console.WriteLine (ex.Message);
			}

			try {
				Xamarin.Forms.Maps.Position pos = new Xamarin.Forms.Maps.Position(e.Position.Latitude, e.Position.Longitude);
				var mapSpan = new Xamarin.Forms.Maps.MapSpan (pos, 0.01, 0.01);
				TuGrua.RequestService.ThisPage._map.MoveToRegion (mapSpan);
                TuGrua.RequestService.ThisPage.MyPosition = e.Position;
                TuGrua.RequestService.ThisPage.CanRequest = true;
                TuGrua.RequestService.ThisPage._requestServiceButton.IsEnabled = true;
			} 
			catch (Exception ex) {
				Console.WriteLine (ex.Message);
                //TuGrua.RequestService.ThisPage.CanRequest = false;
            }

			try {
				TuGrua.RequestService.ThisPage._listenStatus.Text = "Estado:" + e.Position.Timestamp.ToString("G");
				TuGrua.RequestService.ThisPage._listenLatitude.Text = "Latitud: " + e.Position.Latitude.ToString("N4");
				TuGrua.RequestService.ThisPage._listenLongitude.Text = "Longitud: " + e.Position.Longitude.ToString("N4");
			} catch (Exception) {
				Console.WriteLine ("Error with visual elements: RequestService.cs");
			}

		}
コード例 #2
0
ファイル: DriverView.cs プロジェクト: thEpisode/TuGruaMobile
		/// <summary>
		/// Handles the PositionChanged event.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="e">All information about position.</param>
		private void OnPositionChanged(object sender, PositionEventArgs e)
		{
            if (TuGrua.DriverView.ThisPage != null)
            {
                if (TuGrua.DriverView.ThisPage._currentUserStatus == 1)
                {
                    object position = new
                    {
						Id = TuGrua.DriverView.ThisPage.Driver.Cranes.FirstOrDefault().CraneId,
                        Position = e.Position
                    };
                    JObject jsonObject = JObject.FromObject(position);

                    App.io.Emit("SetPositionCrane", jsonObject);
                }

                TuGrua.DriverView.ThisPage._listenStatus.Text = "GPS Listening";
                TuGrua.DriverView.ThisPage._listenLatitude.Text = "Latitud: " + e.Position.Latitude.ToString("N4");
                TuGrua.DriverView.ThisPage._listenLongitude.Text = "Longitud: " + e.Position.Longitude.ToString("N4");
            }
		}
コード例 #3
0
ファイル: Geolocator.cs プロジェクト: thEpisode/TuGruaMobile
		/// <summary>
		///     Handles the <see cref="E:ListenerPositionChanged" /> event.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="e">The <see cref="PositionEventArgs" /> instance containing the event data.</param>
		private void OnListenerPositionChanged(object sender, PositionEventArgs e)
		{
			if (!IsListening) // ignore anything that might come in afterwards
			{
				return;
			}

			lock (_positionSync)
			{
				_lastPosition = e.Position;

				var changed = PositionChanged;
				if (changed != null)
				{
					changed(this, e);
				}
			}
		}