• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Locations.Location类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Android.Locations.Location的典型用法代码示例。如果您正苦于以下问题:C# Location类的具体用法?C# Location怎么用?C# Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Location类属于Android.Locations命名空间,在下文中一共展示了Location类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnLocationChanged

        public void OnLocationChanged(Android.Locations.Location location)
        {
            curLatitudeValue = location.Latitude;
            curLatitude.Text = curLatitudeValue.ToString();
            curLongitudeValue = location.Longitude;
            curLongitude.Text = curLongitudeValue.ToString();

            //check the proximity to the offender location
            if (testLongitudeValue != 0.0 && testLatitudeValue != 0.0)
            {
                Location offenderLocation = new Location(Provider);
                offenderLocation.Longitude = testLongitudeValue;
                offenderLocation.Latitude = testLatitudeValue;
                float meters = location.DistanceTo(offenderLocation);

                if (!insideRadius && (meters < 100)) {
                    insideRadius = true;
                    SendNotification ();
                }
                else if (insideRadius && (meters > 100))
                {
                    insideRadius = false;
                }
                //Toast.MakeText(this, "Distance = " + meters.ToString() + " meters", ToastLength.Short).Show ();
            }
        }
开发者ID:kierstendevenish,项目名称:vowapp2,代码行数:26,代码来源:TestActivity.cs


示例2: OnLocationChanged

 public void OnLocationChanged(Location location)
 {
     // Set CurrentLocation on POIListViewAdapter when a location change is received
       _adapter.CurrentLocation = location;
       // call NotifyDataSetChange() to cause the ListView to be refreshed
       _adapter.NotifyDataSetChanged();
 }
开发者ID:koakh,项目名称:AndroidPoiApp,代码行数:7,代码来源:POIListActivity.cs


示例3: OnLocationChanged

        public void OnLocationChanged(Location location)
        {
            _builder.AppendLine(
                string.Format("Location updated, lat: {0}, long: {1}",
                              location.Latitude, location.Longitude)
            );

            try
            {
                Address address =
                    _geocoder
                        .GetFromLocation(location.Latitude, location.Longitude, 1)
                        .FirstOrDefault();

                if (address != null)
                {
                    _builder.AppendLine(" -> " + address.CountryName);
                }
            }
            catch (IOException io)
            {
                Android.Util.Log.Debug("LocationActivity", io.Message);
            }

            _locationText.Text = _builder.ToString();
        }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:26,代码来源:LocationActivity.cs


示例4: OnLocationChanged

		public async void OnLocationChanged(Location location)
		{
			_currentLocation = location;

			if (_currentLocation == null) {
				state.Text = "Location is not available";

			} else {
				Log.Debug (TAG, string.Format ("{0:f6},{1:f6}", _currentLocation.Latitude, _currentLocation.Longitude));
				//Please use Emulator API23. Geocoder is not available on Emulator API19, got bug
				address = await ReverseGeocodeCurrentLocation ();

				if (address == null) {
					state.Text = "String: No Address";
				} else {
					state.Text = address.GetAddressLine (address.MaxAddressLineIndex - 1);
					int complete = await ccm.HTMLDownload (address.GetAddressLine (address.MaxAddressLineIndex - 1));
					if (complete == 1) {
						int locationIndex = GetNearestLocationIndex ();
						UpdateUI (locationIndex);
					} else {
						UpdateUI (999);
					}
				}
			}
		}
开发者ID:ampentium2,项目名称:MalaysiaAPI,代码行数:26,代码来源:MainActivity.cs


示例5: OnLocationChanged

        public void OnLocationChanged(Location location)
        {
            if (IsEnd) {
                //(FindViewById<TextView>(Resource.Id.txtView)).Append(String.Format ("\r\n\r\nLatitude = {0}, Longitude = {1}", location.Latitude, location.Longitude));
                    }

                    longtitude = location.Longitude;
                    latitude = location.Latitude;
                    // demo geocoder
            //					Geocoder geocdr = new Geocoder(this);
            //
            //					System.Threading.Tasks.Task<IList<Address>> getAddressTask = geocdr.GetFromLocationAsync(location.Latitude, location.Longitude, 5);
            //					adrs = "Trying to reverse geo-code the latitude/longitude...";
            //
            //					IList<Address> addresses = await getAddressTask;
            //
            //					if (addresses.Any())
            //					{
            //						Address addr = addresses.First();
            //						adrs = addr.ToString();
            //					}
            //					else
            //					{
            //						Toast.MakeText(this, "Could not reverse geo-code the location", ToastLength.Short).Show();
            //					}
        }
开发者ID:pafik13,项目名称:PresenterDailyShower,代码行数:26,代码来源:PresentationView.cs


示例6: StartTracking

 public bool StartTracking()
 {
     _currentLocation = null;
     _startTime = DateTime.UtcNow;
     _baseScreen.BackgroundService.LocationChanged += BackgroundService_LocationChanged;
     return _baseScreen.BackgroundService.StartLocationUpdates(true, 0, TimeSpan.Zero);
 }
开发者ID:Fedorm,项目名称:core-master,代码行数:7,代码来源:GPSProvider.cs


示例7: OnCreate

        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            LocHandler = new LocationHandler(Activity.GetSystemService(Activity.LocationService) as LocationManager);
            LocHandler.LocationRequest += (sender, args) =>
            {
                if (args == LocationHandler.messageType.LOCATION)
                {
                    // sets the location initially
                    var loc = (Location)sender;
                    if (followPosition)
                    {
                        lastPosition = loc;
                        SetLocation(loc.Latitude, loc.Longitude);
                    }
                }
                else if (args == LocationHandler.messageType.DISABLED)
                {
                    Toast.MakeText(Activity, Resource.String.ENABLE_GPS, ToastLength.Long).Show();
                }
                else if (args == LocationHandler.messageType.ENABLED)
                {
                    Log.Debug("GPSPROVIDER", "Enabled");
                }
            };

            // initializes the LocationHandler and fires an event if any porblems occur
            LocHandler.Init();
        }
开发者ID:Fanuer,项目名称:fitnessApp,代码行数:30,代码来源:GMapFragment.cs


示例8: OnLocationChanged

        /// <summary>
        /// OnLocationChanged
        /// </summary>
        /// <param name="location"></param>
        public void OnLocationChanged(Location location)
        {
            double lat = location.Latitude;
            double lon = location.Longitude;

            _lat.Text = lat.ToString();
            _lon.Text = lon.ToString();

            var currentloc = new GeoCoordinate(lat, lon);

            foreach (var v in _storeLocations)
            {
                var storelocation = new GeoCoordinate(v.Value.Latitude, v.Value.Longitude);
                var distance = currentloc.GetDistanceTo(storelocation);
                _distanceTo.Text = distance.ToString();

                Context context = this;
                Android.Content.Res.Resources res = context.Resources;
                string minRadius = res.GetString(Resource.String.minRadiusinMeters);

                if (distance < Convert.ToInt16(minRadius))
                {
                    new AlertDialog.Builder(this)
                     .SetMessage("Hey you are near to store, happy shopping!..")
                     .SetNeutralButton("Ok", delegate { }).Show();
                }
                return;
            }
        }
开发者ID:Avinashlikes,项目名称:PUMAs,代码行数:33,代码来源:HomeActivity.cs


示例9: OnLocationChanged

		public async void OnLocationChanged (Location location)
		{
			_currentLocation = location;
			if (_currentLocation == null) {
				_locationText.Text = "Unable to determine your location. Try again in a short while.";
				Insights.Track ("UnableToDetermineLocation");
			} else {
				_locationText.Text = string.Format ("{0:f6},{1:f6}", _currentLocation.Latitude, _currentLocation.Longitude);
				Address address = await ReverseGeocodeCurrentLocation ();
				DisplayAddress (address);
			}
			var apiCall = new ApiCall ();
			await apiCall.Post<TestDriveLog, List<TestDriveLog>> ("test-drive-log", new TestDriveLog () {
				test_drive_id = 1,
				latitude = _currentLocation.Latitude,
				longitude = _currentLocation.Longitude
			}).ContinueWith (t => {
				var tData = new Dictionary<string, string>{
					{"Status", t.Status.ToString()},
					{"Task", t.ToString()},
				};
				if(t.IsCanceled) {
					Insights.Track ("ApiCallCanceled", tData);
				}
				else if(t.IsFaulted) {
					Insights.Track ("ApiCallFaulted", tData);
				}
				else if(t.IsCompleted) {
					Insights.Track ("ApiCallCompleted", tData);
				}
				else {
					Insights.Track ("ApiCallUnknown", tData);
				}
			});
		}
开发者ID:approx,项目名称:protd-app-android,代码行数:35,代码来源:MainActivity.cs


示例10: OnLocationChanged

 public void OnLocationChanged(Location location)
 {
     if (location != null)
     {
         LocationChanged?.Invoke(location.Latitude, location.Longitude);
     }
 }
开发者ID:pgrzmil,项目名称:XamarinResearch,代码行数:7,代码来源:LocationTestService.cs


示例11: GetPoiInformation

		public static JsonArray GetPoiInformation(Location userLocation, int numberOfPlaces)
		{
			if (userLocation == null)
				return null;

			var pois = new List<JsonObject> ();

			for (int i = 0; i < numberOfPlaces; i++)
			{
				var loc = GetRandomLatLonNearby (userLocation.Latitude, userLocation.Longitude);

				var p = new Dictionary<string, JsonValue>(){
					{ "id", i.ToString() },
					{ "name", "POI#" + i.ToString() },
					{ "description", "This is the description of POI#" + i.ToString() },
					{ "latitude", loc[0] },
					{ "longitude", loc[1] },
					{ "altitude", 100f }
				};


				pois.Add (new JsonObject (p.ToList()));
			}

			var vals = from p in pois select (JsonValue)p;

			return new JsonArray (vals);
		}
开发者ID:Redth,项目名称:Wikitude.Xamarin,代码行数:28,代码来源:GeoUtils.cs


示例12: OnLocationChanged

 public void OnLocationChanged (Location location)
 {
     var locationText = FindViewById<TextView> (Resource.Id.locationTextView);
  
     locationText.Text = String.Format ("Latitude = {0}, Longitude = {1}", location.Latitude, location.Longitude);
  
     // demo geocoder
  
     new Thread (new ThreadStart (() => {
         var geocdr = new Geocoder (this);
      
         var addresses = geocdr.GetFromLocation (location.Latitude, location.Longitude, 5);
      
         //var addresses = geocdr.GetFromLocationName("Harvard University", 5);
      
         RunOnUiThread (() => {
             var addrText = FindViewById<TextView> (Resource.Id.addressTextView);
  
             addresses.ToList ().ForEach ((addr) => {
                 addrText.Append (addr.ToString () + "\r\n\r\n");
             });
         });
      
     })).Start ();
 }
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:25,代码来源:LocationActivity.cs


示例13: AnimateTo

		void AnimateTo (Location location)
		{
			if (location != null) {
				_map.AnimateCamera (CameraUpdateFactory.NewLatLngZoom (
					new LatLng (location.Latitude, location.Longitude), _map.MaxZoomLevel - 6));
			}
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:7,代码来源:HomeActivityMapWork.cs


示例14: OnLocationChanged

        public void OnLocationChanged(Location location)
        {
            var currentLocation = new GeoPoint((int) (location.Latitude * 1e6), (int) (location.Longitude * 1e6));

            _mapOverlay.Add(currentLocation, "Current Location");

            _map.Controller.AnimateTo(currentLocation);
        }
开发者ID:jorik041,项目名称:MobileDevelopmentInCSharpBook,代码行数:8,代码来源:LocationActivity.cs


示例15: onButtonClick

 public void onButtonClick(Location location)
 {
     //EditText Lat = FindViewById<EditText> (Resource.Id.
     //EditText Long = FindViewById<EditText> (Resource.Id.EditLong);
     //Lat.Text = location.Latitude.ToString ();
     //Long.Text = location.Longitude.ToString ();
     //EditText Address = FindViewById<EditText>(Resource.Id.EditAddress);
 }
开发者ID:sujaykodamala,项目名称:XamarinSample,代码行数:8,代码来源:WellReadingActivity.cs


示例16: Convert

        static GPSCoordinate Convert(Location location)
        {
            GPSCoordinate result = location != null
                ? new GPSCoordinate(location.Latitude, location.Longitude, location.Time.ToDateTime().ToLocalTime())
                : new GPSCoordinate();

            return result;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:8,代码来源:GPSProvider.cs


示例17: OnLocationChanged

 public void OnLocationChanged(Location location)
 {
     if (IsBetterLocation (location, lastKnownLocation)) {
         lastKnownLocation = location;
         if (geocoder != null)
             SerialScheduler.Factory.StartNew (RefreshGeocodedLocationName);
     }
 }
开发者ID:Andrea,项目名称:FriendTab,代码行数:8,代码来源:Locator.cs


示例18: OnLocationChanged

        public void OnLocationChanged(Location location)
        {
            Unsubscribe();

            if (location != null)
            {
                DoCallback(ToGeolocation(location));
            }
        }
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:9,代码来源:GeoLocationService.cs


示例19: OnLocationChanged

        public void OnLocationChanged(Location location)
        {
            Availability availability;
            if (!_providerAvailabilities.TryGetValue(location.Provider, out availability))
                availability = Availability.Available;

            if (availability == Availability.Available)
                HandleLocationChanged(location);
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:9,代码来源:BaseService.cs


示例20: OnLocationChanged

        public void OnLocationChanged ( Location location )
        {
            if (location == null) return;
            Log.Error (TAG, "Posisi :" + location.Altitude + ", " + location.Longitude + ", akurasi : " + location.Accuracy);

            if (!(location.Accuracy < 500.0f)) return;
            StopLocationUpdates ();
            SendLocationDataToWebsite (location);
        }
开发者ID:ibnuda,项目名称:Lok,代码行数:9,代码来源:LocationService.cs



注:本文中的Android.Locations.Location类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Locations.LocationManager类代码示例发布时间:2022-05-24
下一篇:
C# Hardware.Sensor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap