How to increase the number of clicks on an icon in Google Maps
We are trying to increase the clickable area of the marker on google map. The reason why we want to do is that clicking on the icon sometimes skips the anchor point. We are not reducing the icon size
We assume that one of the properties of the GIcon objects is what we need to change, and tried to change the iconAnchor and infoWindowAnchor property for the GIcon, but that doesn't seem to work.
Anyone point us in the right direction?
a source to share
If you have different icons, it is recommended to create a dynamic image imageMap:
function getImgSize(imgSrc) {
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
return [height,width];
}
var icon = new GIcon(G_DEFAULT_ICON,iconUrl);
var iconSize = getImgSize(iconUrl);
icon.iconSize = new GSize(iconSize[1], iconSize[0]); // set icon size
icon.imageMap = [0,0, icon.iconSize.width,0, icon.iconSize.width,icon.iconSize.height,0,icon.iconSize.height]; // set click area
icon.shadowSize = new GSize(0, 0); // disable shadow
a source to share
Link: http://code.google.com/apis/maps/documentation/reference.html#GIcon
iconAnchor and infoWindowAnchor set where in the image is the actual point on the map and the info window, respectively.
If you want to enlarge the area with clicks, you can do something with the non-IE imageMap property (I've never tried it). However, I think it is best to define a custom GIcon that uses a larger image (padded with transparent space). Unfortunately this is quite a bit of a hack - maybe someone else knows a better way.
a source to share