预装Google地图的标记图片 [英] Preload marker images for Google Maps

查看:86
本文介绍了预装Google地图的标记图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps V3 API创建一个Google地图,其中的标记会在鼠标悬停时更改标记图标。但是,我注意到图标在用户第一次使用该特定标记时会闪烁,并且对于每个标记,我认为这是由于鼠标悬停图像需要一些时间才能下载的。

为了解决这个问题,我正在考虑预加载mouseover图标图像。我不知道这是否适用于每个浏览器,但在现代浏览器(FF 3.6+ ,IE8 / 9(我认为),Safari / Chrome),只需将元素添加到DOM就可以加载它们并缓存它们(即将它们放在页面中隐藏的div),所以下次它们请求,它从你的缓存,而不是服务器,完全消除闪光。


I am using Google Maps V3 API to create a google map where the markers change their marker icons on mouseover. However i notice the icons flicker once the first time the user does it to that specific marker, and to every marker, which I guess is due to the mouseover images taking some time to download.

To solve this, I am thinking of preloading the mouseover icon images. How can I do this?

解决方案

I'm unsure if this works in every browser, but on modern browsers (FF 3.6+, IE8/9 (I think), Safari/Chrome), with cache enabled, simply adding the elements to the DOM loads them and caches them (i.e. put them on the page in a hidden div), so the next time they're requested, its from your cache, not the server, totally eliminating the flash.

这篇关于预装Google地图的标记图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆