Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -21,18 +21,32 @@ |
22 | 22 | * Returns GMarker object on the provided location. It will show a popup baloon |
23 | 23 | * with title and label when clicked, if either of these is set. |
24 | 24 | */ |
25 | | -function createGMarker(point, title, label, icon) { |
| 25 | +function createGMarker( point, title, label, icon ) { |
26 | 26 | var marker; |
27 | 27 | |
28 | | - if (icon != '') { |
29 | | - var iconObj = new GIcon(G_DEFAULT_ICON); |
| 28 | + if ( icon != '' ) { |
| 29 | + var iconObj = new GIcon( G_DEFAULT_ICON ); |
30 | 30 | iconObj.image = icon; |
31 | | - marker = new GMarker(point, {icon:iconObj}); |
| 31 | + |
| 32 | + /* Determine size of icon and pass it in */ |
| 33 | + var newimg = new Image(); |
| 34 | + newimg.src = icon; |
| 35 | + iconObj.iconSize.width = newimg.width; |
| 36 | + iconObj.iconSize.height = newimg.height; |
| 37 | + iconObj.shadow = null; |
| 38 | + |
| 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 | + marker = new GMarker( point, { icon:iconObj } ); |
32 | 46 | } else { |
33 | | - marker = new GMarker(point); |
| 47 | + marker = new GMarker( point ); |
34 | 48 | } |
35 | 49 | |
36 | | - if ((title + label).length > 0) { |
| 50 | + if ( ( title + label ).length > 0 ) { |
37 | 51 | var bothTxtAreSet = title.length > 0 && label.length > 0; |
38 | 52 | var popupText = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label; |
39 | 53 | popupText = '<div style="overflow:auto;max-height:140px;">' + popupText + '</div>'; |