Markus Englund
Markus Englund

Reputation: 11

Is it a good idea to use the chinese google maps api for users in all countries?

I'm using the Google maps javascript api for a website project. The map will not work in mainland China, unless you load the api using a special url. (Explained here).

<script src="http://maps.google.cn/maps/api/js?key=YOUR_API_KEY"> </script>

To make the website work in China, I could use an ip-location service like freegeoip.net to identify chinese users, and serve them the chinese url. But this would require an extra ajax-call which increases loading time for chinese users, and add some complexity to the code.

However, loading the map with the chinese api url works everywhere, while the normal url only works outside of China. Is there any good reason why I shouldn't simply use the chinese url for ALL users? Will it be slower?

Users in China will probably make up less than 5% of users.

Upvotes: 0

Views: 306

Answers (1)

ITChap
ITChap

Reputation: 4742

maps.google.cn and maps.googleapis.com seem to return different results:

dig @8.8.8.8 maps.googleapis.com

; <<>> DiG 9.10.5-P2-RedHat-9.10.5-2.P2.fc25 <<>> @8.8.8.8 maps.googleapis.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35078
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;maps.googleapis.com.       IN  A

;; ANSWER SECTION:
maps.googleapis.com.    0   IN  CNAME   googleapis.l.google.com.
googleapis.l.google.com. 299    IN  A   216.58.221.138
googleapis.l.google.com. 299    IN  A   216.58.200.10
googleapis.l.google.com. 299    IN  A   216.58.221.234
googleapis.l.google.com. 299    IN  A   216.58.199.106
googleapis.l.google.com. 299    IN  A   172.217.25.10
googleapis.l.google.com. 299    IN  A   216.58.197.106
googleapis.l.google.com. 299    IN  A   216.58.199.10

;; Query time: 54 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Sep 06 16:28:16 CST 2017
;; MSG SIZE  rcvd: 194


dig @8.8.8.8 maps.google.cn

; <<>> DiG 9.10.5-P2-RedHat-9.10.5-2.P2.fc25 <<>> @8.8.8.8 maps.google.cn
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40319
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;maps.google.cn.            IN  A

;; ANSWER SECTION:
maps.google.cn.     0   IN  CNAME   ditu.google.cn.
ditu.google.cn.     299 IN  A   108.177.97.94

;; Query time: 57 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Sep 06 16:28:08 CST 2017
;; MSG SIZE  rcvd: 78

So there might be differences in the services provided on each domain. Regarding the speed, querying maps.google.cn from China returns IP addresses in China (the addresses returned in the previous query are located in the US):

dig @114.114.114.114 maps.google.cn

; <<>> DiG 9.10.5-P2-RedHat-9.10.5-2.P2.fc25 <<>> @114.114.114.114 maps.google.cn
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40890
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;maps.google.cn.            IN  A

;; ANSWER SECTION:
maps.google.cn.     38  IN  CNAME   ditu.google.cn.
ditu.google.cn.     207 IN  A   203.208.41.183
ditu.google.cn.     207 IN  A   203.208.41.184
ditu.google.cn.     207 IN  A   203.208.41.191
ditu.google.cn.     207 IN  A   203.208.41.175

;; Query time: 11 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: Wed Sep 06 16:30:54 CST 2017
;; MSG SIZE  rcvd: 126

So there might not be much of a difference in term of speed.

Upvotes: 2

Related Questions