public override string ToString()
        {
            c = (CURL)base.Tag;

            Binding myBinding = new Binding("url");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = c;
            txturl.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("postdata");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = c;
            txtpost.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("variable");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = c;
            txtresult.SetBinding(TextBox.TextProperty, myBinding3);

            Binding myBinding4 = new Binding("isPost");
            myBinding4.Mode = BindingMode.TwoWay;
            myBinding4.Source = c;
            chkpost.SetBinding(CheckBox.IsCheckedProperty, myBinding4);
        


            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = c;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);

            return base.ToString();
        }
Example #2
0
        /// <summary>
        /// Perform geocode function (location string to coordinates).
        /// </summary>
        /// <param name="query">The location string</param>
        /// <returns>The geocoordinates of the location</returns>
        public async Task <GeoCoordinate> Geocode(string query)
        {
            // Clean query
            query = HttpUtility.UrlEncode(query, Encoding.UTF8);

            // Create the request
            var requestResult = await CURL.GET("https://geocoder.api.here.com/6.2/geocode.json",
                                               new Dictionary <string, string> {
                { "app_id", apiKey.AppId },
                { "app_code", apiKey.AppCode },
                { "searchtext", query }
            });

            // Send the request and extract geocoordinates
            try
            {
                dynamic resultObj = JsonConvert.DeserializeObject(requestResult);
                var     view      = resultObj.Response.View;
                var     loc       = view[0].Result[0].Location.DisplayPosition;
                return(new GeoCoordinate
                {
                    Latitude = loc.Latitude,
                    Longitude = loc.Longitude
                });
            }
            catch (JsonException ex)
            {
                logger?.LogError("Geocode error: " + ex.Message);
                return(GeoCoordinate.Unknown);
            }
        }
Example #3
0
        /// <summary>
        /// Perform reverse geocode function (coordinates to location string).
        /// </summary>
        /// <param name="loc">The location's geocoordinates</param>
        /// <param name="radius">(Optional) result accuracy radius</param>
        /// <returns>The string description of the location</returns>
        public async Task <string> ReverseGeocode(GeoCoordinate loc, double radius = 100)
        {
            // Create the request
            var requestResult = await CURL.GET("https://reverse.geocoder.api.here.com/6.2/reversegeocode.json",
                                               new Dictionary <string, string> {
                { "app_id", apiKey.AppId },
                { "app_code", apiKey.AppCode },
                { "prox", loc.Latitude + "," + loc.Longitude + "," + radius },
                { "mode", "retrieveAddresses" },
                { "maxresults", "1" }
            });

            // Send the request and extract the location string
            try
            {
                dynamic resultObj = JsonConvert.DeserializeObject(requestResult);
                var     view      = resultObj.Response.View[0];
                var     res       = view.Result[0];
                return(res.Location.Address.Label);
            }
            catch (JsonException ex)
            {
                logger?.LogError("Reverse geocode error: " + ex.Message);
                return(null);
            }
        }
        public override string ToString()
        {
            c = (CURL)base.Tag;

            Binding myBinding = new Binding("url");

            myBinding.Mode   = BindingMode.TwoWay;
            myBinding.Source = c;
            txturl.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("postdata");

            myBinding2.Mode   = BindingMode.TwoWay;
            myBinding2.Source = c;
            txtpost.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("variable");

            myBinding3.Mode   = BindingMode.TwoWay;
            myBinding3.Source = c;
            txtresult.SetBinding(TextBox.TextProperty, myBinding3);

            Binding myBinding4 = new Binding("isPost");

            myBinding4.Mode   = BindingMode.TwoWay;
            myBinding4.Source = c;
            chkpost.SetBinding(CheckBox.IsCheckedProperty, myBinding4);



            Binding descbinding = new Binding("Description");

            descbinding.Mode   = BindingMode.TwoWay;
            descbinding.Source = c;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);

            return(base.ToString());
        }