Google지도 en에 장소를 추가하는 방법을 알고 있지만 이제는 내 클라이언트가 google maps china에 대한 장소를 추가하고 싶습니다.이 장소는 en에 장소를 추가하는 데 사용하는 코드입니다.중국 Google지도에서 장소를 추가하려면 어떻게해야하나요?
string apiUrl = "https://maps.googleapis.com/maps/api/place/add/json?key=MY_KEY";
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(apiUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Google google = new Google
{
location = new Coord { lat = branch._Latitude, lng = branch._Longitude },
name = branch.BranchName,
phone_number = branch.ContactNO,
address = branch.Address,
types = new string[] { "clothing_store" },
language = "en"
};
var myContent = JsonConvert.SerializeObject(google);
var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.Add("Content-Type", "application/json");
HttpResponseMessage response = await client.PostAsync(apiUrl, byteContent);
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
GoogleResult googleResult = new GoogleResult(data);
return googleResult;
}
}
또한 중국어 버전의 URL을 변경하려고했지만 작동하지 않았습니다. 모드를 디버깅하고 IsSuccessStatusCode가 false로 출력되는 것을 보았습니다 ... 그 값어치가있는 점은 내 가난한 시도입니다.
string apiUrl = "http://maps.google.cn/maps/api/place/add/json?key=MY_KEY";
// ...
Google google = new Google
{
location = new Coord { lat = branch._Latitude_Chi, lng = branch._Longitude_Chi },
name = branch.BranchName_Chi,
phone_number = branch.ContactNO_Chi,
address = branch.Address_Chi,
types = new string[] { "clothing_store" },
language = "zh-CN"
};
도처에서 보았습니다. 아무런 도움이되지 않았으므로, 사전에 감사드립니다.
은 'apiUrl'에서 다른 도메인을 사용하고 있습니다. 'maps.googleapis.com' vs'maps.google.cn' – bradbury9
Google에 따르면 중국지도가 다르게 호스팅되어 있으므로 도메인을 저장하는 것이 논리적으로 정확하다고 생각하지만 아마도 그렇지 않습니다 ... –
의견은 도움이되었습니다. 답변으로 게시하려고합니다. 도움이 될만한 것으로 표시 할 수 있습니다. – bradbury9