当前位置: 首页>>代码示例>>C#>>正文


C# GeoCoordinate类代码示例

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


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

示例1: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();

            bikePaths = new BikePaths();
            trees = Tree.ParseCsv();

            map = new Map();
            map.CredentialsProvider = new ApplicationIdCredentialsProvider("Atvj6eBBbDS6-dL7shp9KmzY-0v0NL2ETYCFoHIDzQwK8_9bJ2ZdRgeMAj0sDs_F");

            // Set the center coordinate and zoom level
            GeoCoordinate mapCenter = new GeoCoordinate(45.504693, -73.576494);
            int zoom = 14;

            // Create a pushpin to put at the center of the view
            Pushpin pin1 = new Pushpin();
            pin1.Location = mapCenter;
            pin1.Content = "McGill University";
            map.Children.Add(pin1);

            bikePaths.AddPathsToMap(map);

            // Set the map style to Aerial
            map.Mode = new Microsoft.Phone.Controls.Maps.AerialMode();

            // Set the view and put the map on the page
            map.SetView(mapCenter, zoom);
            ContentPanel.Children.Add(map);
        }
开发者ID:TryCatch22,项目名称:Project-Beaver,代码行数:30,代码来源:MainPage.xaml.cs

示例2: VehicleTracker

        public VehicleTracker(GeoCoordinate[] waypoints, double minSpeed, double maxSpeed,
            int lowSpeedDelayInSecs,
            int midSpeedDelayInSecs,
            int highSpeedDelayInSecs,
            double speedBetweenPosTolerance
            )
        {
            if (waypoints.Length < 2)
            {
                throw new ArgumentException("Waypoints must be a GeoCoordinate array of at least 2");
            }
            else if (minSpeed < 0 || minSpeed >= maxSpeed)
            {
                throw new ArgumentException("minSpeed must be positive and less than maxSpeed");
            }
            else if (speedBetweenPosTolerance <= 0)
            {
                throw new ArgumentException("Speed tolerance must be greater than zero");
            }
            else if (lowSpeedDelayInSecs <= 0 || midSpeedDelayInSecs <= 0 || highSpeedDelayInSecs <= 0)
            {
                throw new ArgumentException("Time delays must be positive");
            }

            _waypoints = waypoints;
            _minSpeed = minSpeed;
            _maxSpeed = maxSpeed;
            _lowSpeedDelayInSeconds = lowSpeedDelayInSecs;
            _midSpeedDelayInSeconds = midSpeedDelayInSecs;
            _highSpeedDelayInSeconds = highSpeedDelayInSecs;
            _speedBetweenPosTolerance = speedBetweenPosTolerance;
            _random = new Random();
            _speedInMph = _random.NextDouble(_minSpeed, _maxSpeed);
        }
开发者ID:Coruscated,项目名称:VehicleTracker,代码行数:34,代码来源:VehicleTracker.cs

示例3: CreateWaypoint

        //from http://stackoverflow.com/a/17545955
        public static GeoCoordinate CreateWaypoint(GeoCoordinate sourceLocation, double distanceInMeters, double bearingDegrees, double altitude)
        {
            var distanceKm = distanceInMeters / 1000.0;
            var distanceRadians = distanceKm / 6371; //6371 = Earth's radius in km

            var bearingRadians = ToRad(bearingDegrees);
            var sourceLatitudeRadians = ToRad(sourceLocation.Latitude);
            var sourceLongitudeRadians = ToRad(sourceLocation.Longitude);

            var targetLatitudeRadians = Math.Asin(Math.Sin(sourceLatitudeRadians) * Math.Cos(distanceRadians)
                                                  +
                                                  Math.Cos(sourceLatitudeRadians) * Math.Sin(distanceRadians) *
                                                  Math.Cos(bearingRadians));

            var targetLongitudeRadians = sourceLongitudeRadians + Math.Atan2(Math.Sin(bearingRadians)
                                                                             * Math.Sin(distanceRadians) *
                                                                             Math.Cos(sourceLatitudeRadians),
                Math.Cos(distanceRadians)
                - Math.Sin(sourceLatitudeRadians) * Math.Sin(targetLatitudeRadians));

            // adjust toLonRadians to be in the range -180 to +180...
            targetLongitudeRadians = (targetLongitudeRadians + 3 * Math.PI) % (2 * Math.PI) - Math.PI;

            return new GeoCoordinate(ToDegrees(targetLatitudeRadians), ToDegrees(targetLongitudeRadians), altitude);
        }
开发者ID:RouHim,项目名称:Pokemon-Go-Rocket-API,代码行数:26,代码来源:LocationUtils.cs

示例4: ToARunData

 public ARunData ToARunData()
 {
     ARunData data = new ARunData();
     for (int i = 0; i < longitude.Count(); i++)
     {
         GeoCoordinate geoCord = new GeoCoordinate();
         geoCord.Longitude = longitude[i];
         geoCord.Latitude = latitude[i];
         data.geoCollection.Add(geoCord);
     }
    
    
     //data.datetime = JsonConvert.DeserializeObject<DateTime>(datetime, new JavaScriptDateTimeConverter());
     try
     {
         data.datetime = TimeZoneInfo.ConvertTime(datetime, TimeZoneInfo.Local);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "The time will be set to default");
         data.datetime = DateTime.MinValue;
     }
     int dem = (int)IsolatedStorageSettings.ApplicationSettings["RunCount"];
     dem++;
     IsolatedStorageSettings.ApplicationSettings.Save();
     data.BurnedCalories = BurnedCalories;
     data.Duration = Duration;
     data.AvgSpeed = AvgSpeed;
     data.AvgPace = AvgPace;
     data.Distance = Distance;
     data.No = dem;
     data.IsSynced = true;
     return data;
 }
开发者ID:flysofast,项目名称:Just-run---Windows-Phone,代码行数:34,代码来源:ARunUploadData.cs

示例5: AddPoint

        private void AddPoint(Map controlMap, GeoCoordinate geo)
        {
            // With the new Map control:
            //  Map -> MapLayer -> MapOverlay -> UIElements
            //  - Add a MapLayer to the Map
            //  - Add an MapOverlay to that layer
            //  - We can add a single UIElement to that MapOverlay.Content
            MapLayer ml = new MapLayer();
            MapOverlay mo = new MapOverlay();

            // Add an Ellipse UI
            Ellipse r = new Ellipse();
            r.Fill = new SolidColorBrush(Color.FromArgb(255, 240, 5, 5));
            // the item is placed on the map at the top left corner so
            // in order to center it, we change the margin to a negative
            // margin equal to half the width and height
            r.Width = r.Height = 12;
            r.Margin = new Thickness(-6, -6, 0, 0);

            // Add the Ellipse to the Content 
            mo.Content = r;
            // Set the GeoCoordinate of that content
            mo.GeoCoordinate = geo;
            // Add the MapOverlay to the MapLayer
            ml.Add(mo);
            // Add the MapLayer to the Map
            controlMap.Layers.Add(ml);
        }
开发者ID:natsirt20,项目名称:School,代码行数:28,代码来源:Geolocation.xaml.cs

示例6: GetCurrentLocation

        private async void GetCurrentLocation()
        {
            try
            {
                geolocator.DesiredAccuracyInMeters = 50;
                // If the cached location is over 30 minutes old, get a new one
                TimeSpan maximumAge = new TimeSpan(0, 30, 0);
                // If we're trying for more than 5 seconds, abandon the operation
                TimeSpan timeout = new TimeSpan(0, 0, 5);
                Geoposition myLocation = await geolocator.GetGeopositionAsync(maximumAge, timeout);

                GeoCoordinate geoCord = new GeoCoordinate(myLocation.Coordinate.Latitude, myLocation.Coordinate.Longitude);
                waypoints = new List<GeoCoordinate>();
                waypoints.Add(geoCord);
                MyMapControl.Center = geoCord;
                MyMapControl.ZoomLevel = 12;
                AddPoint(MyMapControl, geoCord);

                geolocator.PositionChanged += newPosition;
            }
            catch (Exception exception)
            {
                //if this is an UnauthorizedAccessException:
                //      1) you haven’t included ID_CAP_LOCATION in your app manifest
                //      or
                //      2) user has disabled location in the phone Settings

                // if this is a TimeoutExceeded exception:
                //      the device couldn't get a location in the allotted time
            }

        }
开发者ID:WindowsPhone-8-TrainingKit,项目名称:PRESENTATION-Sensors,代码行数:32,代码来源:MapDemos.xaml.cs

示例7: GetEnterprisesCloseToMyLocation

        public JsonResult GetEnterprisesCloseToMyLocation(string latitude, string longitude)
        {
            var enterprises = Db.Enterprises.GetNearbyEnterprises(latitude, longitude);

            var searchViewModel = new MainSearchViewModel
            {
                Enterprises = new List<LightEnterprise>()
            };

            foreach (var enterpriseViewModel in enterprises.Select(enterprise => new LightEnterprise
            {
                Key = EnterpriseHelper.GetKey(enterprise.Id),
                Name = enterprise.Name,
                LocationInfo = EnterpriseHelper.FormatDisplayStreet(enterprise),
                DistanceFromMyLocation = string.Empty,
                Categories = EnterpriseHelper.GetDisplayLabelsCategories(enterprise.Categories),
                Coordinates = enterprise.Coordinates,

            }))
            {
                searchViewModel.Enterprises.Add(enterpriseViewModel);
            }

            var myCoord = new GeoCoordinate(double.Parse(latitude, CultureInfo.InvariantCulture), double.Parse(longitude, CultureInfo.InvariantCulture));

            foreach (var enterprise in searchViewModel.Enterprises)
            {
                var enterpriseCoord = new GeoCoordinate(enterprise.Coordinates.Lat, enterprise.Coordinates.Lng);

                var distance = myCoord.GetDistanceTo(enterpriseCoord);

                enterprise.DistanceFromMyLocation = string.Format("{0}km", Math.Round((distance / 1000), 1));
            }
            return Json(searchViewModel);
        }
开发者ID:jessetinell,项目名称:imenyn.se,代码行数:35,代码来源:JsonController.cs

示例8: AddPinOnMap

 private void AddPinOnMap()
 {
     geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].longitude));
     geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].longitude));
     Image pinIMG = new Image();
     pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_green.png", UriKind.Relative));
     pinIMG.Width = 50;
     pinIMG.Height = 50;
     MapOverlay myLocationOverlay = new MapOverlay();
     myLocationOverlay.Content = pinIMG;
     myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
     myLocationOverlay.GeoCoordinate = geo1;
     MapLayer myLocationLayer = new MapLayer();
     myLocationLayer.Add(myLocationOverlay);
     mapJourney.Layers.Add(myLocationLayer);
     myLocationLayer = null;
     myLocationOverlay = null;
     pinIMG = null;
     pinIMG = new Image();
     pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_red.png", UriKind.Relative));
     pinIMG.Width = 50;
     pinIMG.Height = 50;
     myLocationOverlay = new MapOverlay();
     myLocationOverlay.Content = pinIMG;
     myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
     myLocationOverlay.GeoCoordinate = geo2;
     myLocationLayer = new MapLayer();
     myLocationLayer.Add(myLocationOverlay);
     mapJourney.Layers.Add(myLocationLayer);
     myLocationLayer = null;
     myLocationOverlay = null;
     pinIMG = null;
     mapJourney.ZoomLevel = ZoomLevel;
     mapJourney.Center = geo2;
 }
开发者ID:kushalSengupta,项目名称:AgeasDriver,代码行数:35,代码来源:FrmMap.xaml.cs

示例9: Init

 public void Init()
 {
     current = new GeoCoordinate(30.623665, -96.334171);
     destination = new GeoCoordinate(30.62505, -96.335362);
     navApp = new DroneControllerApp.AutoNavPage();
     navApp.connectToDrone();
 }
开发者ID:abraxas4,项目名称:AR-Drone-Project,代码行数:7,代码来源:NavTest.cs

示例10: Seanslar_getCompleted

        void Seanslar_getCompleted(seanslar sender)
        {
            loader.IsIndeterminate = false;

            PanoramaRoot.Title = sender.SalonBilgisi.name;
            pItem1.DataContext = sender.SalonBilgisi;
            listFilmler.ItemsSource = sender.SalonBilgisi.movies;

            if (sender.SalonBilgisi.latitude.ToString() != "false")
            {
                SalonCoordinate = new GeoCoordinate(double.Parse(sender.SalonBilgisi.latitude), double.Parse(sender.SalonBilgisi.longitude));
                myMap.SetView(SalonCoordinate, 17);

                pinpoint_salon newPin = new pinpoint_salon();
                MapOverlay newOverlay = new MapOverlay();
                newOverlay.Content = newPin;
                newOverlay.GeoCoordinate = SalonCoordinate;
                newOverlay.PositionOrigin = new Point(0, 0);
                MapLayer MyLayer = new MapLayer();
                MyLayer.Add(newOverlay);
                myMap.Layers.Add(MyLayer);
            }
            else
            {
                myMap.Visibility = Visibility.Collapsed;
                recMap.Visibility = System.Windows.Visibility.Collapsed;
            }

        }
开发者ID:yajinn,项目名称:sinemaciWP,代码行数:29,代码来源:SalonPage.xaml.cs

示例11: LocationForAddressEventArgs

 public LocationForAddressEventArgs(List<LocationForQuery> locations, string query, GeoCoordinate searchNearLocation, Exception error, object state)
     : base(error, state)
 {
     this.query = query;
     this.locations = locations;
     this.searchNearLocation = searchNearLocation;
 }
开发者ID:hungrywolf418,项目名称:WindowsPhone_OneBusAway,代码行数:7,代码来源:LocationForAddressEventArgs.cs

示例12: CalculateDistances

 public void CalculateDistances(GeoCoordinate clientCoordinate)
 {
     foreach (var server in Servers)
     {
         server.Distance = clientCoordinate.GetDistanceTo(server.GeoCoordinate);
     }
 }
开发者ID:xenoputtss,项目名称:NSpeedTest,代码行数:7,代码来源:ServersList.cs

示例13: Show

 /// <summary>
 /// Shows the Bing Maps application centered on the specified location.
 /// </summary>
 /// <param name="center">The location that will be used as the center point for the map.</param>
 /// <exception cref="InvalidOperationException">Center and SearchTerm cannot both be empty.</exception>
 public void Show(GeoCoordinate center)
 {
     new BingMapsTask()
     {
         Center = center,
     }.Show();
 }
开发者ID:HamGuy,项目名称:Cimbalino-Phone-Toolkit,代码行数:12,代码来源:BingMapsService.cs

示例14: ElementText

 /// <summary>
 /// Creates a new dot element.
 /// </summary>
 /// <param name="color"></param>
 public ElementText(int color, Font font, GeoCoordinate center, string text)
 {
     _color = color;
     _font = font;
     _center = center;
     _text = text;
 }
开发者ID:jorik041,项目名称:osmsharp,代码行数:11,代码来源:ElementText.cs

示例15: LocationForAddress

        public void LocationForAddress(string addressString, GeoCoordinate searchNearLocation, object callerState)
        {
            GeocodeRequest request = new GeocodeRequest();
            request.Credentials = new dev.virtualearth.net.webservices.v1.common.Credentials()
            {
                ApplicationId = bingMapsApiKey
            };
            request.Query = addressString;
            request.UserProfile = new UserProfile()
            {
                CurrentLocation = new UserLocation()
                {
                    Latitude = searchNearLocation.Latitude,
                    Longitude = searchNearLocation.Longitude
                },
                DistanceUnit = DistanceUnit.Mile,
                DeviceType = DeviceType.Mobile,
                ScreenSize = new SizeOfint()
                {
                    Width = 480,
                    Height = 700
                }
            };

            GeocodeState state = new GeocodeState()
            {
                Query = addressString,
                SearchNearLocation = searchNearLocation,
                CallerState = callerState
            };

            geocodeService.GeocodeAsync(request, state);
        }
开发者ID:hungrywolf418,项目名称:WindowsPhone_OneBusAway,代码行数:33,代码来源:LocationModel.cs


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