* @version 0.2 */ class Map { /** * Static method that creates and outputs the actual map code based on * the CMap object. Defaults to a Google Map. * @param CMap A Cmap object used to generate the map code. */ function genMap($CMap) { switch($CMap->mapType) { case GOOGLE_MAP: genGoogle::makeMap($CMap); break; case YAHOO_MAP; genYahoo::makeMap($CMap); break; case GEARTH_FILE; genGEarth::makeMap($CMap); break; default: genGoogle::makeMap($CMap); break; } } /** * Private method used by Map's extended classes to calculate the center coordinates * of the map. * @access private * @param CMap $CMap The CMap object used to calculate the center coordinates. * @return Coord The coordinate of the center of the map. */ function calcCenter($CMap) { $x = 0; $topLat = $btmLat = $CMap->location[$x]->getLat(); $topLng = $btmLng = $CMap->location[$x]->getLng(); while ($x < count($CMap->location)) { if ($topLat < $CMap->location[$x]->getLat()) {$topLat = $CMap->location[$x]->getLat();} if ($topLng < $CMap->location[$x]->getLng()) {$topLng = $CMap->location[$x]->getLng();} if ($btmLat > $CMap->location[$x]->getLat()) {$btmLat = $CMap->location[$x]->getLat();} if ($btmLng > $CMap->location[$x]->getLng()) {$btmLng = $CMap->location[$x]->getLng();} $x += 1; } return new Coord( (($topLat + $btmLat) / 2), (($topLng + $btmLng) / 2) ); } /** * Private method used to calculate the span, which is the difference between the most outlier * coordinates. * @access private * @param CMap $CMap The CMap object used to calculate the span lat/long pair. * @return Coord The latitude longitude pair of the span. */ function calcSpan($CMap) { $x = 0; $topLat = $btmLat = $CMap->location[$x]->getLat(); $topLng = $btmLng = $CMap->location[$x]->getLng(); while ($x < count($CMap->location)) { if ($topLat < $CMap->location[$x]->getLat()) {$topLat = $CMap->location[$x]->getLat();} if ($topLng < $CMap->location[$x]->getLng()) {$topLng = $CMap->location[$x]->getLng();} if ($btmLat > $CMap->location[$x]->getLat()) {$btmLat = $CMap->location[$x]->getLat();} if ($btmLng > $CMap->location[$x]->getLng()) {$btmLng = $CMap->location[$x]->getLng();} $x += 1; } // Personal kick out - if not, maps are too close. $spanLat = (($topLat - $btmLat)*1.15); $spanLng = (($topLng - $btmLng)*1.15); return new Coord ( $spanLng, $spanLat); } } ?>