Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -28,19 +28,25 @@ |
29 | 29 | var iconObj = new GIcon( G_DEFAULT_ICON ); |
30 | 30 | iconObj.image = icon; |
31 | 31 | |
32 | | - /* Determine size of icon and pass it in */ |
| 32 | + |
33 | 33 | var newimg = new Image(); |
34 | 34 | newimg.src = icon; |
35 | | - iconObj.iconSize.width = newimg.width; |
36 | | - iconObj.iconSize.height = newimg.height; |
37 | | - iconObj.shadow = null; |
| 35 | + |
| 36 | + // Only do these things when there is an actual width, which there won,t the first time the image is loaded. |
| 37 | + // TODO: this means the image won't have it's correct size when it differs from the default on first load! |
| 38 | + if ( newimg.width > 0 ) { |
| 39 | + /* Determine size of icon and pass it in */ |
| 40 | + iconObj.iconSize.width = newimg.width; |
| 41 | + iconObj.iconSize.height = newimg.height; |
| 42 | + iconObj.shadow = null; |
| 43 | + |
| 44 | + /* Anchor the icon on bottom middle */ |
| 45 | + var anchor = new GPoint(); |
| 46 | + anchor.x = Math.floor( newimg.width / 2 ); |
| 47 | + anchor.y = newimg.height; |
| 48 | + iconObj.iconAnchor = anchor; |
| 49 | + } |
38 | 50 | |
39 | | - /* Anchor the icon on center */ |
40 | | - var anchor = new GPoint(); |
41 | | - anchor.x = Math.floor( newimg.width / 2 ); |
42 | | - anchor.y = Math.floor( newimg.height / 2 ); |
43 | | - iconObj.iconAnchor = anchor; |
44 | | - |
45 | 51 | marker = new GMarker( point, { icon:iconObj } ); |
46 | 52 | } else { |
47 | 53 | marker = new GMarker( point ); |