#include "pch.h"
#include "MainPage.xaml.h"
//추가한 include, 프로젝트 전체에서 여러번 사용하면 pch.h에 넣으면 된다.
#include <sstream>

using namespace DaumExample;

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

//추가한 namespace
using namespace Windows::Storage::Streams;
using namespace Windows::Data::Json;
using namespace Windows::Web::Http;
using namespace concurrency;
using namespace std;

// 빈 페이지 항목 템플릿은 http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 에 문서화되어 있습니다.

MainPage::MainPage()
{
	InitializeComponent();
	wostringstream fragment;
//https://developers.daum.net/ 에서 발급한 키값으로 변경하면 됩니다.
	wstring key = L"";
	fragment << "&apikey=" << key << "&q=" << L"서울 강북구 삼양로173길 7 농협장학관";
	HttpClient^ http = ref new HttpClient();

	auto p = http->GetAsync(ref new Uri("https://apis.daum.net/local/geo/addr2coord?output=json" + ref new String(fragment.str().c_str())));
	create_task(p).then([=](HttpResponseMessage^ httpMessage) {
		String^ message = httpMessage->Content->ToString();
		JsonValue^ val = JsonValue::Parse(message);
		auto channel = val->GetObject()->GetNamedObject("channel");
		auto item = channel->GetObject()->GetNamedArray("item");
		auto latitude = item->GetObjectAt(0)->GetNamedNumber("lat");
		auto longitude = item->GetObjectAt(0)->GetNamedNumber("lng");
	});
}
.

+ Recent posts