开发者

Preload marker images for Google Maps

开发者 https://www.devze.com 2023-03-16 19:56 出处:网络
I am using Google Maps V3 API to create a google map where the markers change their marker icons开发者_C百科 on mouseover. However i notice the icons flicker once the first time the user does it to th

I am using Google Maps V3 API to create a google map where the markers change their marker icons开发者_C百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消