Пример #1
0
        public static GoogleGetLocation GetAddress(GoogleMapPoint origin)
        {
            var originString = string.Format("{0},{1}", origin.Lat, origin.Lng);

            var requestUrl = string.Format("https://maps.googleapis.com/maps/api/geocode/json?latlng={0}", originString);
            var client     = new WebClient();
            var result     = client.DownloadString(requestUrl);

            return(JsonConvert.DeserializeObject <GoogleGetLocation>(result));
        }
Пример #2
0
        public static GoogleGetDistance GetDistance(GoogleMapPoint origin, GoogleMapPoint destination)
        {
            var originString      = string.Format("{0},{1}", origin.Lat, origin.Lng);
            var destinationString = string.Format("{0},{1}", destination.Lat, destination.Lng);

            var requestUrl = string.Format("https://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}", originString, destinationString);
            var client     = new WebClient();
            var result     = client.DownloadString(requestUrl);

            return(JsonConvert.DeserializeObject <GoogleGetDistance>(result));
        }
Пример #3
0
        public static GoogleResultDirection GetDirection(GoogleMapPoint origin, GoogleMapPoint destination)
        {
            var originString      = string.Format("{0},{1}", origin.Lat, origin.Lng);
            var destinationString = string.Format("{0},{1}", destination.Lat, destination.Lng);

            var requestUrl = string.Format("https://maps.google.com/maps/api/directions/json?origin={0}&destination={1}&sensor=false", originString, destinationString);

            var client = new WebClient();
            var result = client.DownloadString(requestUrl);

            return(JsonConvert.DeserializeObject <GoogleResultDirection>(result));
        }