AcquireAPIKey(); $this->MapGenerator = new Geomatics_MapGenerator($this->Key); # Configure initial settings $this->MapGenerator->SetMapHeight(500); # In pixels $this->MapGenerator->SetMapWidth(500); # In pixels $this->MapGenerator->SetMapZoom(12); # 5 mi per inch $this->MapGenerator->SetMapControl('SMALL_PAN_ZOOM'); $this->MapGenerator->SetMarkerIconColor('SLATE'); $this->MapGenerator->SetMarkerIconStyle('GT_FLAT'); $this->MapGenerator->SetHomeMarkerIconColor('SLATE'); $this->MapGenerator->SetHomeMarkerIconStyle('GT_PILLOW'); } ############################################################################################################################################################## ## Acquisition Methods ############################################################################################################################################################## /** * Loads GoogleMaps API Key from configuration. * * Sets key on success, otherwise faults on error. * @return void */ private function AcquireAPIKey() { # Load API key $Key = Zend_Registry::getInstance()->configuration->gmaps->api_key; # Error if key is not valid if (empty($Key)) trigger_error('GoogleMaps API Key undefined!', E_USER_ERROR); else $this->Key = $Key; } /** * Generates script path for GoogleMaps that includes key. * * Returns URL of script location. * @return string */ public function AcquireKeyScriptPath() { return $this->MapGenerator->AcquireKeyScriptPath(); } ############################################################################################################################################################## ## Public Methods ############################################################################################################################################################## /** * Add an address to the current map generation iteration. Geocoding will automatically be performed on the address. * @param string|array $Address Address to be added. Can be an array of addresses in Address => Info Content format. Empty or equivalent value for info will result in the address being used. */ public function AddAddress($Address) { if (is_array($Address)) { foreach ($Address AS $IAddress => $IInfo) { $this->MapGenerator->SetAddress($IAddress); # Set info content if supplied if (!empty($IInfo)) $this->MapGenerator->SetInfoWindowText($IInfo); } } else $this->MapGenerator->SetAddress($Address); } /** * Generate container div for map. * * Returns source HTML for map div. * @return string */ public function RetrieveMap() { return $this->MapGenerator->MapHolder(); } /** * Generate scripts for map. If script has already been requested, this function will do nothing. * * Returns source script/HTML for map. * @param boolean $DuplicateScript If provided and true, script will be regenerated and returned even if it has been sent previously. * @return string */ public function RetrieveScript($DuplicateScript = false) { # Include javascript if it has not already been sent if (!$this->JavascriptSent || $DuplicateScript) { # Remember that scripts have been sent $this->JavascriptSent = true; $Script = $this->MapGenerator->InitJS() . $this->MapGenerator->UnloadMap(); } else $Script = ''; return $Script; } /** * Set the initial map controls for current iteration. * @param int $Control Control type to set. * Options: * 0 for no controls, * 1 or SMALL_PAN_ZOOM, * 2 or LARGE_PAN_ZOOM, * 3 or SMALL_ZOOM */ public function SetControls($Control) { if (!$Control) { $this->MapGenerator->SetMapControl('NONE'); return; } switch ($Control) { case 'SMALL_PAN_ZOOM': case 1: $this->MapGenerator->SetMapControl('SMALL_PAN_ZOOM'); break; case 'LARGE_PAN_ZOOM': case 2: $this->MapGenerator->SetMapControl('LARGE_PAN_ZOOM'); break; case 'SMALL_ZOOM': case 3: $this->MapGenerator->SetMapControl('SMALL_ZOOM'); break; default: $this->MapGenerator->SetMapControl('NONE'); } } /** * Set the initial map height for current iteration. * @param int $Height Height to set in pixels. */ public function SetHeight($Height) { $this->MapGenerator->SetMapHeight($Height); } /** * Set the initial marker icon color scheme for current iteration. * @param int $IconColorScheme Color scheme of icons to apply. * Options: * 0 or SLATE, * 1 for PACIFICA, * 2 or YOSEMITE, * 3 or MOAB, * 4 or GRANITE_PINE, * 5 or DESERT_SPICE, * 6 or CABO_SUNSET, * 7 or TAHITI_SEA, * 8 or POPPY, * 9 or NAUTICA, * 10 or DEEP_JUNGLE */ public function SetIconColorScheme($IconColorScheme) { if (!$IconColorScheme) { $this->MapGenerator->SetMarkerIconColor('SLATE'); return; } switch ($IconColorScheme) { case 'PACIFICA': case 1: $this->MapGenerator->SetMarkerIconColor('PACIFICA'); break; case 'YOSEMITE': case 2: $this->MapGenerator->SetMarkerIconColor('YOSEMITE'); break; case 'MOAB': case 3: $this->MapGenerator->SetMarkerIconColor('MOAB'); break; case 'GRANITE_PINE': case 4: $this->MapGenerator->SetMarkerIconColor('GRANITE_PINE'); break; case 'DESERT_SPICE': case 5: $this->MapGenerator->SetMarkerIconColor('DESERT_SPICE'); break; case 'CABO_SUNSET': case 6: $this->MapGenerator->SetMarkerIconColor('CABO_SUNSET'); break; case 'TAHITI_SEA': case 7: $this->MapGenerator->SetMarkerIconColor('TAHITI_SEA'); break; case 'POPPY': case 8: $this->MapGenerator->SetMarkerIconColor('POPPY'); break; case 'NAUTICA': case 9: $this->MapGenerator->SetMarkerIconColor('NAUTICA'); break; case 'DEEP_JUNGLE': case 10: $this->MapGenerator->SetMarkerIconColor('DEEP_JUNGLE'); break; default: $this->MapGenerator->SetMarkerIconColor('SLATE'); } } /** * Set the initial marker icon style for current iteration. * @param int $IconStyle Style of icons to apply. * Options: * 0 or GT_FLAT, * 1 for FLAG, * 2 or GT_PILLOW, * 3 or HOUSE, * 4 or PIN, * 5 or PUSH_PIN, * 6 or STAR */ public function SetIconStyle($IconStyle) { if (!$IconStyle) { $this->MapGenerator->SetMarkerIconStyle('GT_FLAT'); return; } switch ($IconStyle) { case 'FLAG': case 1: $this->MapGenerator->SetMarkerIconStyle('FLAG'); break; case 'GT_PILLOW': case 2: $this->MapGenerator->SetMarkerIconStyle('GT_PILLOW'); break; case 'HOUSE': case 3: $this->MapGenerator->SetMarkerIconStyle('HOUSE'); break; case 'PIN': case 4: $this->MapGenerator->SetMarkerIconStyle('PIN'); break; case 'PUSH_PIN': case 5: $this->MapGenerator->SetMarkerIconStyle('PUSH_PIN'); break; case 'STAR': case 6: $this->MapGenerator->SetMarkerIconStyle('STAR'); break; default: $this->MapGenerator->SetMarkerIconStyle('GT_FLAT'); } } /** * Set the initial home marker icon color scheme for current iteration. * @param int $HomeIconColorScheme Color scheme of home icon to apply. * Options: * 0 or SLATE, * 1 for PACIFICA, * 2 or YOSEMITE, * 3 or MOAB, * 4 or GRANITE_PINE, * 5 or DESERT_SPICE, * 6 or CABO_SUNSET, * 7 or TAHITI_SEA, * 8 or POPPY, * 9 or NAUTICA, * 10 or DEEP_JUNGLE */ public function SetHomeIconColorScheme($HomeIconColorScheme) { if (!$HomeIconColorScheme) { $this->MapGenerator->SetHomeMarkerIconColor('SLATE'); return; } switch ($HomeIconColorScheme) { case 'PACIFICA': case 1: $this->MapGenerator->SetHomeMarkerIconColor('PACIFICA'); break; case 'YOSEMITE': case 2: $this->MapGenerator->SetHomeMarkerIconColor('YOSEMITE'); break; case 'MOAB': case 3: $this->MapGenerator->SetHomeMarkerIconColor('MOAB'); break; case 'GRANITE_PINE': case 4: $this->MapGenerator->SetHomeMarkerIconColor('GRANITE_PINE'); break; case 'DESERT_SPICE': case 5: $this->MapGenerator->SetHomeMarkerIconColor('DESERT_SPICE'); break; case 'CABO_SUNSET': case 6: $this->MapGenerator->SetHomeMarkerIconColor('CABO_SUNSET'); break; case 'TAHITI_SEA': case 7: $this->MapGenerator->SetHomeMarkerIconColor('TAHITI_SEA'); break; case 'POPPY': case 8: $this->MapGenerator->SetHomeMarkerIconColor('POPPY'); break; case 'NAUTICA': case 9: $this->MapGenerator->SetHomeMarkerIconColor('NAUTICA'); break; case 'DEEP_JUNGLE': case 10: $this->MapGenerator->SetHomeMarkerIconColor('DEEP_JUNGLE'); break; default: $this->MapGenerator->SetHomeMarkerIconColor('SLATE'); } } /** * Set the initial home marker icon style for current iteration. * @param int $HomeIconStyle Style of home icon to apply. * Options: * 0 or GT_FLAT, * 1 for FLAG, * 2 or GT_PILLOW, * 3 or HOUSE, * 4 or PIN, * 5 or PUSH_PIN, * 6 or STAR */ public function SetHomeIconStyle($HomeIconStyle) { if (!$HomeIconStyle) { $this->MapGenerator->SetHomeMarkerIconStyle('GT_FLAT'); return; } switch ($HomeIconStyle) { case 'FLAG': case 1: $this->MapGenerator->SetHomeMarkerIconStyle('FLAG'); break; case 'GT_PILLOW': case 2: $this->MapGenerator->SetHomeMarkerIconStyle('GT_PILLOW'); break; case 'HOUSE': case 3: $this->MapGenerator->SetHomeMarkerIconStyle('HOUSE'); break; case 'PIN': case 4: $this->MapGenerator->SetHomeMarkerIconStyle('PIN'); break; case 'PUSH_PIN': case 5: $this->MapGenerator->SetHomeMarkerIconStyle('PUSH_PIN'); break; case 'STAR': case 6: $this->MapGenerator->SetHomeMarkerIconStyle('STAR'); break; default: $this->MapGenerator->SetHomeMarkerIconStyle('GT_FLAT'); } } /** * Set the initial map width for current iteration. * @param int $Width Width to set in pixels. */ public function SetWidth($Width) { $this->MapGenerator->SetMapWidth($Width); } /** * Set the initial map zoom for current iteration. * @param int $Width Width to set in pixels. */ public function SetZoom($Zoom) { $this->MapGenerator->SetMapZoom($Zoom); } } ?>