예제 #1
0
        internal static KaKaoBase Search2(string query)
        {
            KaKaoBase  mls     = new KaKaoBase();
            string     site    = "https://dapi.kakao.com/v2/local/search/keyword.json";
            string     rquery  = string.Format("{0}?query={1}", site, query);
            WebRequest request = WebRequest.Create(rquery);
            string     rkey    = "52c05f422e54b1daeb00ef11feac0331";
            string     header  = "KakaoAK " + rkey;

            request.Headers.Add("Authorization", header);
            WebResponse          response = request.GetResponse();
            Stream               stream   = response.GetResponseStream();
            StreamReader         reader   = new StreamReader(stream, Encoding.UTF8);
            String               json     = reader.ReadToEnd();
            JavaScriptSerializer js       = new JavaScriptSerializer();
            dynamic              dob      = js.Deserialize <dynamic>(json);
            dynamic              docs     = dob["documents"];

            object[] buf = docs;
            int      length = buf.Length;
            string   lname = docs[0]["place_name"]; double x = double.Parse(docs[0]["x"]); double y = double.Parse(docs[0]["y"]);

            mls.Name = lname;
            mls.Lng  = x;
            mls.Lat  = y;
            return(mls);
        }
예제 #2
0
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbox_locale.SelectedIndex == -1)
            {
                return;
            }
            KaKaoBase ml = lbox_locale.SelectedItem as KaKaoBase;

            object[] ps = new object[] { ml.Lat, ml.Lng };
            wb.InvokeScript("setCenter", ps);
        }
예제 #3
0
        private void place_name_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (place_nameList.SelectedIndex == -1)
            {
                return;
            }

            Search search_name   = (Search)place_nameList.SelectedItem;
            string search_result = search_name.place_name;

            KaKaoBase mls = KakaoAPI.Search2(search_result);

            object[] ps = new object[] { mls.Lat, mls.Lng };
            try
            {
                wb.InvokeScript("setCenter", ps);
            }
            catch (Exception)
            {
                log.Error("place_name_SelectionChanged에서 오류 발생");
                MessageBox.Show("오류가 발생했습니다. 로그를 확인하세요.", "오류", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }