* @version 0.1 */ class CMap { var $location; var $locCount; var $center; var $span; var $apiKey; var $mapType; var $controlSize; var $displayType; var $container; var $zoom; /** * CMap constructor. Defaults to a google map with full controls. * @param string $container The name of the div containing the map. As noted above: Cannot name the div "map". */ function CMap() { $this->location = ""; $this->locCount = 0; $this->center = NULL; $this->span = NULL; $this->bounds = NULL; $this->apiKey = 0; $this->container = NULL; $this->controlSize = LRG_CONTROLS; $this->mapType = GOOGLE_MAP; //Google Map Specific Fields $this->displayType = CART_MAP; // Yahoo Specific Fields $this->zoom = NULL; } /** * addLocation adds Location objects to CMap's location array in sequential order. It updates the location * counter by one. * @param Location $loc The Location object to save. */ function addLocation($loc) { $this->location[$this->locCount] = $loc; $this->locCount += 1; } /** * Sets the name of the div container Google or Yahoo maps will be displayed in. As of 19/12/2005 the containing div * cannot be named "map" as it will break a Yahoo generated map. This is not CMap's fault but rather a variable conflict * in Yahoo's map script. * @param string $name A string of the name of the containing div. */ function setContainer($name) { $this->container = $name; } /** * Some of the online mapping utilities require an identifier or key. Use setKey to use your domain or projects * unique identifier. They can be obtained from the online mapping api sites. For example, you can get Google Map * keys at: {@link http://www.google.com/apis/maps/signup.html http://www.google.com/apis/maps/signup.html} and a * yahoo one at: {@link http://api.search.yahoo.com/webservices/register_application http://api.search.yahoo.com/webservices/register_application} * @param string $key A string of the key value. */ function setKey($key) { $this->apiKey = $key; } /** * Allows the user to manually set the center of the map by specifying a latitude and longitude in decimal degress. * If the center is not manually set, it is calculated during the drawMap() function using the inputted locations. * @param float $lat The latitude in decimal degrees. * @param float $lng The longitude in decimal degrees. */ function setCenter($lat, $lng) { $this->center = new Coord($lat, $lng); } /** * Allows the user to manually set the span of the map by specifying a latitude difference and longitude difference * in decimals. If the span is not manually set, it is calculated during the drawMap() function using the inputted locations. * @param float $x The difference in latitude or x-axis. * @param float $y The difference in longitude or y-axis. */ function setSpan($x, $y) { $this->span = new Coord($x, $y); } /** * Allows the user to manually set the zoom level for a Yahoo Map. This is a somewhat arbitrary integer from 1-16 with * 1 being the most zoomed in and each consecutive number afterwards being twice as zoomed out. If no zoom is set manually * it is calculated during the drawMap() function using the inputted locations. * @param int $lvl The integer of the zoom level. An integer between 1 and 16. */ function setZoom($lvl) { $this->zoom = $lvl; } /** * Allows the user to set the map type between all supported maps using one of the supplied constants. * @param string @mapType The type of map to display, GOOGLE_MAP, YAHOO_MAP, or GEARTH_FILE are currently supported. */ function setMapType($mapType) { $this->mapType = $mapType; } /** * Currently a Google Specific method, allows to change the default display type (satellite, hybrid, or cartography). * @param string $displayType The valud of the display type, CART_MAP, SATELLITE_MAP, or HYRBID_MAP are currently supported. */ function setDisplayType($displayType) { $this->displayType = $displayType; } /** * Most of the online maps allow different sized controls for the maps. This allows you to set the size using * one of the constants. * @param string $size The value of the control size, LRG_CONTROLS or SML_CONTROLS are currenly supported. */ function setControlSize($size) { $this->controlSize = $size; } /** * Will take all the supplied or default input and draw the map in the containing div. */ function drawMap() { Map::genMap($this); } } ?>