{"id":68,"date":"2017-05-01T12:55:06","date_gmt":"2017-05-01T03:55:06","guid":{"rendered":"https:\/\/www.studio-jt.co.kr\/%ec%a4%91%ea%b5%ad%ec%97%90%ec%84%9c-%ea%b5%ac%ea%b8%80%eb%a7%b5-api-%ec%82%ac%ec%9a%a9%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%a0%9c-%eb%b0%8f-%ed%95%b4%ea%b2%b0%ec%b1%85\/"},"modified":"2026-11-15T18:46:49","modified_gmt":"2026-11-15T09:46:49","slug":"using-google-maps-api-in-china","status":"publish","type":"post","link":"https:\/\/www.studio-jt.co.kr\/en\/using-google-maps-api-in-china\/","title":{"rendered":"Using the Google Maps API in China &#8211; Problem and Solution"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-689895\" src=\"https:\/\/www.studio-jt.co.kr\/wp-content\/uploads\/2017\/05\/jt-blog-googleapi5.jpg\" alt=\"\" width=\"850\" height=\"290\"><\/p>\n<h2>The Problem<\/h2>\n<p>The Google Maps API does not work properly in China. This is because the <a href=\"https:\/\/www.google.com\/maps\" target=\"_blank\" rel=\"noopener noreferrer\">maps.google.com<\/a> domain, which is normally used to display Google Maps, is blocked in China.<br \/>\nBut don&#8217;t worry! Google already knows about this issue and provides a solution.<\/p>\n<h2>The Solution<\/h2>\n<p>If you replace google.com, Google&#8217;s default API domain, with google.cn, you can use Google Maps in China as well. This domain runs on Google&#8217;s servers in China and uses http.<\/p>\n<p>Example:<br \/>\n<strong><code>https:\/\/maps.google.com\/maps\/api\/js?region=KR<\/code><\/strong><\/p>\n<p>Solution<br \/>\n<strong><code><span style=\"color: #ff0000;\">http<\/span>:\/\/maps.google<span style=\"color: #ff0000;\">.cn<\/span>\/maps\/api\/js?region=KR<\/code><\/strong><\/p>\n<p>When using Google Maps, don&#8217;t forget to set the region parameter to KR if you want <a href=\"\/en\/google-maps-dokdo-east-sea-labels\/\" target=\"_blank\" rel=\"noopener\">Dokdo and the East Sea<\/a> to be displayed!!!<\/p>\n<p><span style=\"font-size: 0.8em;\">Update 2018.08.11: On the demo page, calls to Google Maps China are currently being blocked because of a compatibility issue with SSL, which causes the browser to treat it as an insecure script. We will update this post as soon as we confirm the issue.<\/span><\/p>\n<p>If you visit the demo page from a country other than China, both maps display normally. If you visit it from China, only the map on the right is displayed. (See below for how to test a page remotely from a server in China.)<\/p>\n<h2>Optimizing the Code<\/h2>\n<p>Requesting Google Maps from Chinese servers is slow from countries outside China, so it is best to optimize your code so that only users in China use google.cn.<br \/>\nYou can use a PHP library such as the <a href=\"https:\/\/github.com\/maxmind\/GeoIP2-php\" target=\"_blank\" rel=\"noopener noreferrer\">maxmind geoip php api<\/a> to serve a different Google Maps domain based on the user&#8217;s IP.<br \/>\nIf you can&#8217;t use a geoip library, another option is to check the user&#8217;s browser language and serve the China Google Maps API only when it is Chinese.<br \/>\n(You could also use the HTML5 geolocation API, but we don&#8217;t recommend it because it asks the user for permission.)<\/p>\n<h3>PHP example:<\/h3>\n<p>[php]<br \/>\n$lang = substr($_SERVER[&#8216;HTTP_ACCEPT_LANGUAGE&#8217;], 0, 2);<\/p>\n<p>if($lang === &#8216;zh&#8217;){<br \/>\n$google_map_url = &#8216;http:\/\/maps.google.cn\/maps\/api\/js?region=KR&#8217;;<br \/>\n}else{<br \/>\n$google_map_url = &#8216;https:\/\/maps.google.com\/maps\/api\/js?region=KR&#8217;;<br \/>\n}<br \/>\necho &#8216;&amp;lt;script src=&quot;&#8217;.$google_map_url.&#8217;&quot;&amp;gt;&amp;lt;script&amp;gt;&#8217;;<br \/>\n[\/php]<\/p>\n<h3>JavaScript example:<\/h3>\n<p>If you use JavaScript, you need to load the script asynchronously.<br \/>\njQuery reference used in the example: <a href=\"https:\/\/api.jquery.com\/jquery.getscript\/\" target=\"_blank\" rel=\"noopener noreferrer\">$.getScript<\/a><\/p>\n<p>[js]<br \/>\nvar google_map_url = &#8221;;<br \/>\nvar lang = navigator.language || navigator.userLanguage;<\/p>\n<p>if(lang === &#8216;zh&#8217;){<br \/>\ngoogle_map_url = &#8216;http:\/\/maps.google.cn\/maps\/api\/js?region=KR&#8217;;<br \/>\n}else{<br \/>\ngoogle_map_url = &#8216;https:\/\/maps.google.com\/maps\/api\/js?region=KR&#8217;;<br \/>\n}<\/p>\n<p>$.getScript( google_map_url ).done(function( script, textStatus ) {<br \/>\n\/\/ Build your Google Map here<br \/>\n}<br \/>\n[\/js]<\/p>\n<h2>Testing Google Maps<\/h2>\n<p>Finally, you need to check from a computer environment in China that Google Maps connects properly.<\/p>\n<p><del>The simplest way is to use a service like <a href=\"https:\/\/www.webpagetest.org\" target=\"_blank\" rel=\"noopener noreferrer\">webpagetest.org<\/a>.<br \/>\nThis service provides screenshots showing how a website looks from a server in China.<\/del><\/p>\n<p><del>Go to <a href=\"https:\/\/www.webpagetest.org\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.webpagetest.org<\/a>, select &#8220;Yangzhou, China (Chrome,Firefox)&#8221; as the location, and run the test.<\/del><\/p>\n<p><del>When the test is complete and the results page appears, click &#8220;Screenshot&#8221; to see how your website looks in China. (It may take a while depending on how many people are in the queue.)<\/del><\/p>\n<p><strong>Update: <\/strong>webpagetest.org has announced that it no longer offers a location in China. At JT, we found a new way to test websites from a server in China. With the <a href=\"https:\/\/www.geoscreenshot.com\/country\/china\" target=\"_blank\" rel=\"noopener noreferrer\">geoscreenshot.com\/country\/china<\/a> service, you can see how your website looks in China.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-691297\" src=\"https:\/\/www.studio-jt.co.kr\/wp-content\/uploads\/2017\/04\/geoscreenshot-com-jt-china-google-map.png\" alt=\"Checking the Google Maps integration in China\" width=\"1024\" height=\"760\"><\/p>\n<h2>Reference Links<\/h2>\n<p>Google offical FAQ :&nbsp;<a href=\"https:\/\/developers.google.com\/maps\/faq#china_ws_access\">https:\/\/developers.google.com\/maps\/faq#china_ws_access<\/a><\/p>\n<h2>Notes<\/h2>\n<p>The demo page and sample code do not include a Google API key, but we strongly recommend adding a Google API key to prevent problems that may occur in production.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you know that the Google Maps API does not work in China?<br \/>\nWe had to solve this problem on one of our projects.<br \/>\nHere is how STUDIO-JT solved it.<\/p>\n","protected":false},"author":1,"featured_media":139,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[13],"class_list":["post-68","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":1,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":2269,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/posts\/68\/revisions\/2269"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.studio-jt.co.kr\/en\/wp-json\/wp\/v2\/categories?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}