Return to Snippet

Revision: 20502
at November 17, 2009 10:30 by rccc


Updated Code
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);

}

Revision: 20501
at November 17, 2009 10:29 by rccc


Initial Code
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);

}

Initial URL
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/effe106b5ee6d6cd/3dc16de627bfe1e0?lnk=gst&q=clustering

Initial Description


Initial Title
get bounds of an icon/marker

Initial Tags
javascript

Initial Language
JavaScript