예제 #1
0
        public void ValidateLocation(string location, TrafficDialogViewController.GetLocationActions locActions)
        {
            Console.WriteLine("Validating locations...");
            string url = string.Format("https://maps.googleapis.com/maps/api/geocode/json?latlng={0}&sensor=true&key={1}", location, GoogleApiKey);

            MakeCallAndGetJsonResponse(url, false,
                                       (string jsonString, string time) => {
                if (ParseValidateLocationResponse(jsonString, false, locActions))
                {
                }
            }
                                       );

            Console.WriteLine("");
        }
예제 #2
0
        public bool ParseValidateLocationResponse(string jsonString, bool fromAddress, TrafficDialogViewController.GetLocationActions locActions)
        {
            try {
                JArray locjson = ParseJObject(jsonString, "results");

                if ((locjson != null) && (locjson.Count() > 0))
                {
                    Console.Write(string.Format("Location from Coordinates * {0}{1}{2}", locjson[0]["formatted_address"], locjson[0]["geometry"]["location"]["lat"], locjson[0]["geometry"]["location"]["lng"]));
                    AddressUpdate(locjson[0]["formatted_address"].ToString(), locjson[0]["geometry"]["location"]["lat"].ToString(), locjson[0]["geometry"]["location"]["lng"].ToString(), fromAddress, "", locActions);
                }
            } catch (Exception ex) {
                Console.WriteLine("Error" + ex.ToString());
            }
            return(true);
        }