/ 博客 / 4737阅

Leaflet Maps Marker地图加载太慢的解决方法

(English translation is at the end)

自从我“发现”Leaflet Maps Marker并把它作为自己最喜欢的WordPress地图插件,以及与原作者Robert Harm联系并光荣的参与了插件汉化工作一直到现在以来,这款插件就以其专业的设计、经常的更新、功能的完善牢牢占据了我的心。使用至今,曾出现过的一些小问题都已被勤奋的作者Robert一一订正。但是有一个问题一直无法解决:在中国,我们伟大的墙把谷歌的很多服务ban掉了,Maps Marker提供的一些服务也未能幸免,哪怕不使用Google Maps,其在加载地图时依旧出现等待时间巨长(一般超过40秒)的情况。症状:

Leaflet Maps Marker
Leaflet Maps Marker

经仔细研究,是因为在加载QR代码“在全屏模式创建QR代码图片”时使用了chart.useso.com的缘故。

<a href=https://chart.useso.com/chart?chs=150x150&amp;cht=qr&amp;chl=/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?layer=1 target="_blank" title="在全屏模式创建QR代码图片"><img src=/wp-content/plugins/leaflet-maps-marker/inc/img/icon-qr-code.png width="14" height="14" alt="QR-code-logo" class="lmm-panel-api-images" /></a>

因此只需将之禁掉便可。方法:插件“地图默认值”→“新层地图的默认值”→“QR代码”前的√号去除即可。

Leaflet Maps Marker
Leaflet Maps Marker
Leaflet Maps Marker
Leaflet Maps Marker

如果用不到的话,所有API链接都可以去除,不过个人建议可以保存XML、全屏两个代码,方便别人下载你的地标。

另外,建议中国大陆用户把默认地图设为“Mapquest (OSM)”或“必应地图”(必应地图要API key),并且不要将谷歌地图设为可选地图(设置→地图默认值→控制台提供的基础地图→将所有谷歌地图反选)。

经测试,速度有数倍的提高,至少快了20多秒!

English:

A Tip To Solve Slow Loading Of Leaflet Maps Marker For Mainland China Users

Since I ever "discovered" Leaflet Maps Marker and set it as my personal favorite WordPress plugin, then contacted with Robert Harm and took part in the translation job, the plugin stays in my heart for its professional design, frequent updates, and multiple functions. Till now, the appeared small problems had been solved by its diligent author Robert. But, there is one problem leaving unsolved: In our great Mainland China, our great firewall by Ministry of Industry and IT had banned or slowed down a lot of Google services including Google Maps because of disputes and distrusts with Google. So is Maps Marker's map services. Even I don't use Google Maps in Maps Marker, it takes super long loading time (generally more than 40 seconds) when maps are loaded. (See above screenshot 1)

After some research, I found the reason is because chart.useso.com was used when loading QR code "Create QR code image for standalone map in full-screen mode". (See above HTML codes)

So all we have to do is just banning this code. Go to "Map defaults" ->"Default values for new layer maps"->uncheck "QR code". (See above screenshot 2 & 3)

If APIs are not used, I suggest uncheck all API links, exclude XML and Full-screen mode for others to download your markers.

Moreover, I suggest all Mainland China users change the default map to "Mapquest (OSM)" or "Bing Map" (API key needed). I also suggest not to use Google Maps (Settings->Map defaults->Available basemaps in control box->uncheck all Google map services) if you wish to speed up map loading time.

My test shows that after these changes, map loading time is shortened a lot: At least 20 seconds faster!

下载本软件


2014/2/10

经过前期一系列的测试,终于发现原来是Google的http协议导致了被墙,也就是说,Google喜欢用的https://是可以正常通过墙的,而http://是不可以的。跟软件作者联系后,Robert将本功能加入进去,彻底解决了此问题!

具体请见Robert在Pro版v1.5.6的更新日志中的阐述:

support for conditional SSL loading of Javascript for Google Maps

So far, the Google javascript need for Google Maps to displayed properly was loaded by default via https. John from China found out, that this was causing performance issues on his server, resulting in a notable lag when using Google Maps as basemap (thanks for the report!). I am not sure if this is an issue specific to China, as I also learned that with certain webserver configurations loading mixed ressources via https can result in poorer performance.

Anyway I changed this now with pro v1.5.6 and load Google Javascript only via https, if the site is also loaded via https.

# 写于十二年前,改于二年前
           

5

  1. chojemmy

    有点专业啊。你的博客回复没有邮件提醒

    Google Chrome 23 · Windows 7
    1. S̆̈

      @chojemmy不专业啊,没有涉及编程,只是汉化以及软件设置而已。

      这个博客我是没有设置提醒,不过可以加上。现在应该好了。

      p.s. 去过你的博客,只能说,翻墙太累了,我表示评论无能。何不搞个提供国内外主机的国内服务商呢?

      Google Chrome 23 · Windows 7
  2. Healson

    特专业,看完我还明白是什么意思

    Firefox 18 · Windows XP
    1. Healson

      @Healson更正:特专业,看完我还没明白是什么意思

      Firefox 18 · Windows XP
    2. S̆̈

      @Healson@Healson 看不懂吗?点这个页面就知道我在说什么了……

      Internet Explorer 8 · Windows XP

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注