views:

715

answers:

4

EDIT: Mozilla fixed the bug. This thread is dead.

EDIT: This is a Mozilla bug. See this thread: https://bugzilla.mozilla.org/show%5Fbug.cgi?id=501853

I have a sprite I use for my images here: http://www.trailbehind.com/site%5Fmedia/images/sprite.png

In FireFox 3.5, the sprite seems to get fetched every time I render an icon on my map, you can see the behavior in the Firebug Net Panel when you load this page and/or pan the map: http://www.trailbehind.com/node/1148091/

I had previously had similar problems to this in Internet Explorer, but I had eventually gotten this working in Safari 3/4, FF 2/3, and IE 6/7/8. Now, something is wrong in FF 3.5 :(

I tried to put this code in the of the document to prec-cache the image, but to no avail:

  var pre = new Image();
  pre.src = "/site_media/images/sprite.png";

Here's the code that later creates the map markers (and fetches the sprite image again). It might be GMaps related - it doesn't seem to fetch a sprite to draw each icon or otheer image on the left... just the map.

//returns an image-like GIcon based on a sprite  
function getGIconSprite(attr) {
  var myicon = new GIcon(G_DEFAULT_ICON);
  myicon.sprite = {image:"/site_media/images/sprite.png", top:0};
  myicon.iconSize = new GSize(16,16);
  myicon.iconAnchor = new GPoint(8,8);
  myicon.shadow = null;
  myicon.sprite.left = attr.offset*16;
  return myicon;
}
A: 

it is gmaps JS related. you should use a pointer (copy of variable) to the existing variable, such as:

defaulticon.sprite = {image:"/site_media/images/sprite.png", top:0};

myicon.sprite = defaulticon.sprite;
myicon2.sprite = defaulticon.sprite;
etc.
dusoft
Hmmm, so I tried toing this, but it still seems to fetch multiple sprites. Is this code right:var defSprite = {image:"/site_media/images/sprite.png", top:0};//returns an image-like GIcon based on a spritefunction getGIconSprite(attr) { var myicon = new GIcon(G_DEFAULT_ICON); myicon.iconSize = new GSize(16,16); myicon.iconAnchor = new GPoint(8,8); myicon.shadow = null; myicon.sprite = defSprite; myicon.sprite.left = attr.offset*16; return myicon;}
Andrew Johnson
i am not sure then. i know i had a similar problem with images being reloaded and then used one to define all points...
dusoft
+1  A: 

There seems to be a problem with FireFox 3.5 loading images from the server and not using the cache properly. Google "firefox 3.5 not caching images" and you will notice a lot of people noticing this problem.

A: 

I see you use Lighttpd. You might want to use Module: mod_expire for your static files. Set them to expire after a month or even more. You can find more information about this on Yahoo.

Kristof Neirynck
+1  A: 

This is official FireFox 3.5 bug. Simple hack for it is to create two class for all snipped object: one common for all with background image, and the second one with background position. That's all kids!)