Source: maps/limbs/location/LocationStrategy.js


/**
 * @class
 * A strategy class for computing the location of target objects.
 * 
 * The location of the target object is needed to determine the direction the object lies and
 * thereby the placement of the LIMB at the edge of the map.
 * For a 1 dimensional marker the location is trivial - it is the marker's position.
 * For 2 dimensional shapes this strategy is used to derive a point from shape of the target object.
 * 
 * This base class does nothing. Use one of the concrete sub-classes, e.g. BoundsEdgeLocationStrategy
 * to choose your preferred algorithm.
 * 
 * @constructor
 * @param {lucid.maps.limbs.location.LocationStrategyOptions} options  The options controlling the location calculation.
 */
lucid.maps.limbs.location.LocationStrategy = function( options )
{
	var markerConstructor = (new google.maps.Marker()).constructor;
	var polylineConstructor = (new google.maps.Polyline()).constructor;
	var polygonConstructor = (new google.maps.Polygon()).constructor;
	var rectangleConstructor = (new google.maps.Rectangle()).constructor;
	var circleConstructor = (new google.maps.Circle()).constructor;
	
	
	/**
	 * @param {google.maps.Marker|google.maps.Polyline|google.maps.Polygon|google.maps.Rectangle|google.maps.Circle} target  The given target.
	 * @returns {function}  The function that will compute the location for the type of target given.
	 */
	this.getMethodForTargetType = function( target )
	{
		if (target.constructor == markerConstructor)
		{
			return this.computeMarkerLocation;
		}
		if (target.constructor == polylineConstructor)
		{
			return this.computePolylineLocation;
		}
		if (target.constructor == polygonConstructor)
		{
			return this.computePolygonLocation;
		}
		if (target.constructor == rectangleConstructor)
		{
			return this.computeRectangleLocation;
		}
		if (target.constructor == circleConstructor)
		{
			return this.computeCircleLocation;
		}
	};
	
	/**
	 * @param {google.maps.Marker|google.maps.Polyline|google.maps.Polygon|google.maps.Rectangle|google.maps.Circle} target  The given target.
	 * @param {google.maps.LatLngBounds} mapBounds  The bounds of the current map view.
	 * @returns {google.maps.LatLng}  The location of the target. The actual location will vary between different strategy classes.
	 */
	this.computeLocation = function( target, mapBounds )
	{
		var computeLocationOfTarget = this.getMethodForTargetType( target );
		
		return computeLocationOfTarget( target, mapBounds );
	};
	
	this.computeMarkerLocation = function( target, mapBounds )
	{
		return null;
	};
	
	this.computePolylineLocation = function( target, mapBounds )
	{
		return null;
	};
	
	this.computePolygonLocation = function( target, mapBounds )
	{
		return null;
	};
	
	this.computeRectangleLocation = function( target, mapBounds )
	{
		return null;
	};
	
	this.computeCircleLocation = function( target, mapBounds )
	{
		return null;
	};
	
};


/**
 * @type {object}
 */
lucid.maps.limbs.location.LocationStrategyOptions = {};