コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: hanseartic/FreeCars
        private void pinCurrentMapCenterAsSecondaryTile()
        {
            try {
                var usCultureInfo = new CultureInfo("en-US");
                var latitude      = map.Center.Latitude.ToString(usCultureInfo.NumberFormat);
                var longitude     = map.Center.Longitude.ToString(usCultureInfo.NumberFormat);

                var reverseGeocode = new ReverseGeocode(true);
                reverseGeocode.Updated += OnReverseGeocodeUpdated;
                reverseGeocode.QueryAsync(latitude, longitude, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.ToUpper());
            } catch (Exception) { }
        }
コード例 #2
0
        public async Task CanReverseGeocodePoint(string rootUrl, string relativeUrl, double x, double y, int wkid)
        {
            var gateway        = new PortalGateway(rootUrl);
            var reverseGeocode = new ReverseGeocode(relativeUrl.AsEndpoint())
            {
                Location = new Point
                {
                    X = x,
                    Y = y,
                    SpatialReference = new SpatialReference {
                        Wkid = wkid
                    }
                }
            };
            var response = await gateway.ReverseGeocode(reverseGeocode);

            Assert.Null(response.Error);
            Assert.NotNull(response.Address);
            Assert.NotNull(response.Location);
        }
コード例 #3
0
ファイル: GeocodeTests.cs プロジェクト: alpascual/ArcGIS.PCL
        public async Task CanReverseGeocodePoint()
        {
            var gateway        = new GeocodeGateway(new ServiceStackSerializer());
            var reverseGeocode = new ReverseGeocode("/World/GeocodeServer/".AsEndpoint())
            {
                Location = new Point
                {
                    X = 174.775505,
                    Y = -41.290893,
                    SpatialReference = new SpatialReference {
                        Wkid = SpatialReference.WGS84.LatestWkid
                    }
                }
            };
            var response = await gateway.ReverseGeocode(reverseGeocode);

            Assert.Null(response.Error);
            Assert.NotNull(response.Address);
            Assert.NotNull(response.Location);
            Assert.Equal(response.Address.CountryCode, "NZL");
        }
コード例 #4
0
        public async Task CanReverseGeocodePoint(string rootUrl, string relativeUrl, double x, double y, int wkid)
        {
            var gateway        = new PortalGateway(rootUrl);
            var reverseGeocode = new ReverseGeocode(relativeUrl)
            {
                Location = new Point
                {
                    X = x,
                    Y = y,
                    SpatialReference = new SpatialReference {
                        Wkid = wkid
                    }
                }
            };
            var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() =>
            {
                return(gateway.ReverseGeocode(reverseGeocode));
            });

            Assert.Null(response.Error);
            Assert.NotNull(response.Address);
            Assert.NotNull(response.Location);
        }
コード例 #5
0
 /// <summary>
 /// Call the reverse geocode operation.
 /// </summary>
 /// <param name="reverseGeocode"></param>
 /// <param name="ct">Optional cancellation token to cancel pending request</param>
 /// <returns></returns>
 public virtual Task <ReverseGeocodeResponse> ReverseGeocode(ReverseGeocode reverseGeocode, CancellationToken ct = default(CancellationToken))
 {
     return(Get <ReverseGeocodeResponse, ReverseGeocode>(reverseGeocode, ct));
 }
コード例 #6
0
 public virtual Task <ReverseGeocodeResponse> ReverseGeocode(ReverseGeocode reverseGeocode)
 {
     return(ReverseGeocode(reverseGeocode, CancellationToken.None));
 }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: hanseartic/FreeCars
        private void RefreshPOIsOnMap()
        {
            if (refreshDelay >= DateTime.Now)
            {
                var bw = new BackgroundWorker();
                bw.DoWork += (sender, args) => {
                    Thread.Sleep(100);
                    RefreshPOIsOnMap();
                };
                bw.RunWorkerAsync();
                return;
            }
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke(RefreshPOIsOnMap);
                return;
            }
            ((App)Application.Current).RefreshPOIs();

            if (IsolatedStorageSettings.ApplicationSettings.Contains("car2goSelectedCity"))
            {
                if ("autodetect" != ((string)IsolatedStorageSettings.ApplicationSettings["car2goSelectedCity"]).ToLower())
                {
                    return;
                }
            }

            var usCultureInfo = new CultureInfo("en-US");

            var latitude  = map.Center.Latitude.ToString(usCultureInfo.NumberFormat);
            var longitude = map.Center.Longitude.ToString(usCultureInfo.NumberFormat);

            var reverseGeocode = new ReverseGeocode(true);

            reverseGeocode.Updated += delegate(object o, EventArgs args) {
                var response     = (o as ReverseGeocode).Results;
                var localityName = "";
                if (null != response)
                {
                    if ("" == localityName)
                    {
                        foreach (var address_component in response.SelectMany(result => result.address_components.Where(
                                                                                  address_component => address_component.types.Contains("locality") && address_component.types.Contains("political"))))
                        {
                            localityName = address_component.long_name.ToLower();
                            break;
                        }
                    }
                }
                if ((IsolatedStorageSettings.ApplicationSettings.Contains("current_map_city") &&
                     ((string)IsolatedStorageSettings.ApplicationSettings["current_map_city"] != localityName)) || !IsolatedStorageSettings.ApplicationSettings.Contains("current_map_city"))
                {
                    App.SetAppSetting("current_map_city", localityName);

                    ((App)Application.Current).RootFrame.Dispatcher.BeginInvoke(() => {
                        try {
                            (App.Current.Resources["car2go"] as Car2Go).LoadPOIs();
                        } catch { }
                    });
                }
            };
            reverseGeocode.QueryAsync(latitude, longitude, "DE");
        }