Your IP : 216.73.216.240


Current Path : /home/j/u/v/juvelize/www/components/com_zhgooglemap/helpers/
Upload File :
Current File : /home/j/u/v/juvelize/www/components/com_zhgooglemap/helpers/map_center.php

<?php
/*------------------------------------------------------------------------
# com_zhgooglemap - Zh GoogleMap Component
# ------------------------------------------------------------------------
# author    Dmitry Zhuk
# copyright Copyright (C) 2011 zhuk.cc. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
# Websites: http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
-------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

/**
 * Zh GoogleMap Helper
 */
abstract class comZhGoogleMapCenterHelper
{

	public static function get_map_center_button(
						$center_object,
						$map_object,
						$map_zoom,
						$button_text,
						$button_type,
						$button_position,
						$button_style,
						$button_object,
						$imgpathUtils,
						$imgWidth,
						$imgHeight,
						$imgFile,
						$feature4control						
						)
	{
		$switcher   =	comZhGoogleMapCenterHelper::private_get_center_switcher(
								$button_object,
								$map_zoom
						);
		$initializer   =	comZhGoogleMapCenterHelper::private_get_center_initializer(
								$button_object,
								$map_zoom
						);
		$scripttext = 	comZhGoogleMapCenterHelper::private_get_center_button(
						$center_object,
						$map_object,
						$map_zoom,
						$button_text,
						$button_type,
						$button_position,
						$button_style,
						$button_object,
						$initializer,
						$switcher,
						$imgpathUtils,
						$imgWidth,
						$imgHeight,
						$imgFile,
						$feature4control						
						);

		return	$scripttext;
	}
	
	private static function private_get_center_switcher(
						$button_object,
						$map_zoom
						)
	{
		$scripttext = '';

		$scripttext .= '  '.$button_object.'ButtonControl.prototype.clickPanel = function() {' ."\n";
		$scripttext .= '        this.v_map.setCenter(this.v_latlng);' ."\n";
		if ($map_zoom != "do not change")
		{
			$scripttext .= '        this.v_map.setZoom(this.v_zoom);' ."\n";
		}
		$scripttext .= '  }' ."\n";

		return $scripttext;
		
	}
	
	private static function private_get_center_initializer(
						$button_object,
						$map_zoom
						)
	{
		$scripttext = '';

		$scripttext .= '  '.$button_object.'ButtonControl.prototype.initializePanel = function() {' ."\n";
		$scripttext .= '        this.v_map.setCenter(this.v_latlng);' ."\n";
		if ($map_zoom != "do not change")
		{
			$scripttext .= '        this.v_map.setZoom(this.v_zoom);' ."\n";
		}
		$scripttext .= '  }' ."\n";

		return $scripttext;
		
	}
	
	
	private static function private_get_center_button(
						$center_object,
						$map_object,
						$map_zoom,
						$button_text,
						$button_type,
						$button_position,
						$button_style,
						$button_object,
						$initializer_function,
						$switcher_function,
						$imgpathUtils,
						$imgWidth,
						$imgHeight,
						$imgFile,
						$feature4control
						)
	{
		$scripttext = '';
		$buttonStyle = '';

		if ($feature4control == 1)
		{
			$buttonStyle = '';
		}
		else
		{
			$buttonStyle = '2';
		}		
				
		
		
		switch ($button_type) 
		{
			case 1:
				$buttonStyle .= '-star';
			break;
			case 2:
				$buttonStyle .= '-star';
			break;
			default:
			break;
		}		
						
		$scripttext .= 	$switcher_function;
		$scripttext .= 	$initializer_function;
		
		
		$scripttext .= ' function '.$button_object.'ButtonControl(controlDiv, pi_map, pi_latlng';
		if ($map_zoom != "do not change")
		{
			$scripttext .= ', pi_zoom';
		}
		$scripttext .= ') {' ."\n";

		$scripttext .= '  this.v_latlng = pi_latlng;' ."\n";
		$scripttext .= '  this.v_map = pi_map;' ."\n";
		if ($map_zoom != "do not change")
		{
			$scripttext .= '  this.v_zoom = pi_zoom;' ."\n";
		}
		
		// We set up a variable for the 'this' keyword since we're adding event
		// listeners later and 'this' will be out of scope.
		$scripttext .= '  var control = this;' ."\n";
		
		// Set CSS styles for the DIV containing the control
		// Setting padding to 5 px will offset the control
		// from the edge of the map.
		$scripttext .= '  controlDiv.style.padding = \'5px\';' ."\n";

		// Set CSS for the control border.
		$scripttext .= '  var controlUI = document.createElement(\'DIV\');' ."\n";
		$scripttext .= '  controlUI.className = "zhgm-'.$button_style.'-button-ui'.$buttonStyle.'";' ."\n";
		$scripttext .= '  controlUI.title = "'.$button_text.'";' ."\n";
		$scripttext .= '  controlDiv.appendChild(controlUI);' ."\n";

		// Set CSS for the control interior.
		$scripttext .= '  var controlText = document.createElement(\'DIV\');' ."\n";
		$scripttext .= '  controlText.className = "zhgm-'.$button_style.'-button-text'.$buttonStyle.'";' ."\n";

		switch ($button_type) 
		{
			case 1:
				$scripttext .= '  controlText.innerHTML = \'<img style="border: 0px none; padding: 0px; margin: 0px; width: '.$imgWidth.'px; height: '.$imgHeight.'px;" src="'.$imgpathUtils.$imgFile.'.png">\';';				
			break;
			case 2:
				$scripttext .= '  controlText.innerHTML = \'<img style="border: 0px none; padding: 0px; margin: 0px; width: '.$imgWidth.'px; height: '.$imgHeight.'px;" src="'.$imgpathUtils.$imgFile.'.png">\';';				
			break;
			case 11:
				$scripttext .= '  controlText.innerHTML = "'.$button_text.'";' ."\n";
			break;
			case 12:
				$scripttext .= '  controlText.innerHTML = "'.$button_text.'";' ."\n";
			break;
			default:
				$scripttext .= '  controlText.innerHTML = "";' ."\n";
			break;
		}
		
		$scripttext .= '  controlUI.appendChild(controlText);' ."\n";

		// Setup the click event listeners
		$scripttext .= '  google.maps.event.addDomListener(controlUI, \'click\', function() {' ."\n";
		$scripttext .= '    control.clickPanel();' ."\n";
		$scripttext .= '  });' ."\n";

		$scripttext .= '  control.initializePanel();' ."\n";
		
		$scripttext .= ' }' ."\n";

		$scripttext .= '  var '.$button_object.'ButtonControlDiv = document.createElement(\'DIV\');' ."\n";
		$scripttext .= '  var '.$button_object.'ButtonControl = new '.$button_object.'ButtonControl('.$button_object.'ButtonControlDiv, '.$map_object.', '.$center_object;
		if ($map_zoom != "do not change")
		{
			$scripttext .= ', '.$map_zoom;
		}
		$scripttext .= ');' ."\n";

		$scripttext .= '  '.$button_object.'ButtonControlDiv.index = 1;' ."\n";
		
		if (isset($button_position)) 
		{
			$controlPosition ="";
			switch ($button_position) 
			{
				case 0:
				break;
				case 1:
						$controlPosition = 'google.maps.ControlPosition.TOP_CENTER';
				break;
				case 2:
						$controlPosition = 'google.maps.ControlPosition.TOP_LEFT';
				break;
				case 3:
						$controlPosition = 'google.maps.ControlPosition.TOP_RIGHT';
				break;
				case 4:
						$controlPosition = 'google.maps.ControlPosition.LEFT_TOP';
				break;
				case 5:
						$controlPosition = 'google.maps.ControlPosition.RIGHT_TOP';
				break;
				case 6:
						$controlPosition = 'google.maps.ControlPosition.LEFT_CENTER';
				break;
				case 7:
						$controlPosition = 'google.maps.ControlPosition.RIGHT_CENTER';
				break;
				case 8:
						$controlPosition = 'google.maps.ControlPosition.LEFT_BOTTOM';
				break;
				case 9:
						$controlPosition = 'google.maps.ControlPosition.RIGHT_BOTTOM';
				break;
				case 10:
						$controlPosition = 'google.maps.ControlPosition.BOTTOM_CENTER';
				break;
				case 11:
						$controlPosition = 'google.maps.ControlPosition.BOTTOM_LEFT';
				break;
				case 12:
						$controlPosition = 'google.maps.ControlPosition.BOTTOM_RIGHT';
				break;
				default:
					$controlPosition = '';
				break;
			}
		}
		
		if ($controlPosition != "")
		{
			$scripttext .= '  '.$map_object.'.controls['.$controlPosition.'].push('.$button_object.'ButtonControlDiv);' ."\n";
		}
		
		return $scripttext;
		
	}
	
	
	
	
}