Exemplo n.º 1
0
        private string getNearByPlaceID(Models.Geo geo, string type)
        {
            if (string.IsNullOrEmpty(type))
            {
                type = "subway_station";
            }

            string jsonResult = "";

            using (WebClient wc = new WebClient())
            {
                string _url = $"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={geo.lat},{geo.lng}&radius=1000&type={type}&key={Authority.KeyUtility.GMapMrtKey}";
                jsonResult = wc.DownloadString(_url);
            }
            dynamic j = JsonConvert.DeserializeObject(jsonResult);

            return(j.results[0].place_id);//nearby mrt place id
        }
Exemplo n.º 2
0
        private Models.Geo parseGeo(string jStr)
        {
            dynamic jsonResult = JsonConvert.DeserializeObject(jStr);

            Models.Geo _geo = new Models.Geo();
            try
            {
                _geo.statName         = jsonResult.results[0].address_components[0].long_name;
                _geo.formattedAddress = jsonResult.results[0].formatted_address;
                _geo.lat      = jsonResult.results[0].geometry.location.lat.Value;
                _geo.lng      = jsonResult.results[0].geometry.location.lng.Value;
                _geo.place_id = jsonResult.results[0].place_id;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(_geo);
        }
Exemplo n.º 3
0
        private Models.Geo getBaseGeo(string location)
        {
            var url = $"https://maps.googleapis.com/maps/api/geocode/json?address={location}&key=AIzaSyBlEnOEgknWMReRy_XAKq2ars1I0zhEuc8";

            if (string.IsNullOrEmpty(location))
            {
                return(new Models.Geo());
            }
            string jsonResult = "";

            using (WebClient wc = new WebClient())
            {
                jsonResult = wc.DownloadString(url);
            }
            dynamic j = JsonConvert.DeserializeObject(jsonResult);

            Models.Geo _geo = new Models.Geo();
            _geo.lat = j.results[0].geometry.location.lat.Value;
            _geo.lng = j.results[0].geometry.location.lng.Value;
            return(_geo);//nearby mrt place id
        }