Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preload marker images for Google Maps

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?

like image 934
thedethe Avatar asked Dec 08 '25 03:12

thedethe


1 Answers

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.

like image 114
Benno Avatar answered Dec 10 '25 16:12

Benno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!