/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getIconBounds(marker){ var iconSize, iconAnchorPoint, iconAnchorPointOffset, iconBoundsPointSw, iconBoundsPointNe, iconBoundsLatLngSw, iconBoundsLatLngNe; iconSize=marker.getIcon().iconSize; iconAnchorPoint=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getLatLng(), map.getZoom()); iconAnchorPointOffset=marker.getIcon().iconAnchor; iconBoundsPointSw=new GPoint(iconAnchorPoint.x- iconAnchorPointOffset.x, iconAnchorPoint.y-iconAnchorPointOffset.y +iconSize.height); iconBoundsPointNe=new GPoint(iconAnchorPoint.x- iconAnchorPointOffset.x+iconSize.width, iconAnchorPoint.y- iconAnchorPointOffset.y); iconBoundsLatLngSw=map.getCurrentMapType().getProjection().fromPixelToLatLng(iconBoundsPointSw, map.getZoom()); iconBoundsLatLngNe=map.getCurrentMapType().getProjection().fromPixelToLatLng(iconBoundsPointNe, map.getZoom()); return new GLatLngBounds(iconBoundsLatLngSw, iconBoundsLatLngNe); }
Comments
