ditu.google.cn无法访问

Lithromantic
  • 2
新手上路,请多包涵

今天突然发现以前的项目google地图无法显示了,看了一下,是ditu.google.cn/maps/js资源拿不到了,有没有碰到同样问题的?怎么解决的呀

回复
阅读 6k
5 个回答
save丶
  • 1
新手上路,请多包涵

貌似2020.2.3之后ditu.google.cn就不能用了。你有解决方案了告诉我下,我目前正在找。

Hello Google Maps Platform Customer,

We are writing to let you know that due to low usage, Google Maps Platform APIs will no longer be hosted on the google.cn domain starting February 3, 2020. An application you own has recently called a Google Maps Platform API from the google.cn domain.

What do I need to know?
Starting February 3, 2020, Google Maps Platform APIs will no longer be hosted from the google.cn domain. All requests to load Google Maps Platform APIs from the google.cn domain will return an error.

What do I need to do?
In order to avoid errors, you will need to update your project(s) that call a Google Maps Platform API from the google.cn domain to use the googleapis.com domain instead.

You can search your code for google.cn/maps to identify where the update needs to be made. If you would like to add Chinese localization to your requests, you can use the region and language parameters.

The following example updates a request from google.cn to googleapis.com:

Invalid request to google.cn domain
http://maps.google.cn/maps/api/js?key=YOUR_API_KEY
Valid request to googleapis.com domain with region and language
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&region=CN&language=zh-CN
Your project(s) listed below have made requests to the google.cn domain in the past week and may be affected by this change:
havt
  • 2
新手上路,请多包涵
Damien
  • 1
新手上路,请多包涵
yhj945
  • 2
新手上路,请多包涵

分享一下我的解决方法吧,需要的话可以试一下。
1、打开https://google.cn/maps/api/js...,下载js到本地,在格式化后第10行左右,也可查找里面所有的'www.google.cn';'www.google.com';'maps.google.cn';'maps.google.com',替换为'google.cn',然后本地引入;
2、打开https://google.cn/maps-api-v3...,下载js到本地,
在格式化后第3886行左右,也可查找里面的'"http://www.google.cn" : "https://www.google.cn"',替换为'"http://google.cn" : "https://google.cn"',然后本地引入。
主要就修改这两个js本地引入,就不贴代码了,目前我所使用的功能都可以正常使用,不知道后续会不会有问题。
不修改就使用代理吧

wpbestway
  • 2
新手上路,请多包涵

使用leaflet.js,可以解决部分问题,而且服务较为稳定,不会出现突然挂掉的情况,推荐使用,另外leaflet也提供谷歌地图版;
例子请参考:https://www.myuniuni.com/glob...

map.jpg

你知道吗?

宣传栏