grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026<?php
/**
 * Google map JoomlaBuff
 * @package mod_jb_smart_login
 * @copyright Copyright (C) 2015 JoomlaBuff http://joomlabuff.com. All rights reserved.
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 * @websites http://joomlabuff.com
 * @support Forum - http://joomlabuff.com/support
 */
defined ( '_JEXEC' ) or die ();
class ModJBGoogleMapHelper {
	public static function addMedia($params, $module) {
		$document = JFactory::getDocument ();
		$app = JFactory::getApplication ();
		$template = $app->getTemplate ();
		JHtml::_ ( 'jquery.framework' );
		$language = JFactory::getLanguage ();
		$mapApi = '//maps.google.com/maps/api/js?sensor=true&language=' . $language->getTag ();
		if ($params->get ( 'weather' )) {
			$mapApi .= '&libraries=weather';
		}
		$document->addScript ( $mapApi );
		
		$document->addStyleSheet ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/css/custom-icons.css' );
		$document->addStyleSheet ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/css/styles.css' );
		$document->addStyleSheet ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/css/jbgooglemap.css' );
		$document->addStyleSheet ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/css/animsition.min.css' );
		$document->addScriptVersion ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/js/modernizr.min.js' );
		$document->addScriptVersion ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/js/jquery.easing.1.3.min.js' );
		// $document->addScriptVersion ( JUri::root ( true ) . '/modules/mod_jb_googlemap/assets/js/scripts.js' );
		
		$markerIcon = JUri::root () . $params->get ( 'map_marker', 'modules/mod_jb_googlemap/assets/images/default_marker.png' );
		
		$latitude = $params->get ( 'latitude', 51.508742 );
		$longitude = $params->get ( 'longitude', - 0.120850 );
		$location_title = $params->get ( 'location_title', '' );
		$location_address = $params->get ( 'location_address', '' );
		$address = "";
		if ($params->get ( 'show_address', 0 )) {
			$address .= $params->get ( 'address', '' );
			$address = trim ( preg_replace ( '/\s\s+/', ' ', $address ) );
		}
		
		// map settings
		$zoom = $params->get ( 'map_zoom', 9 );
		$mapType = $params->get ( 'map_type', 'hybrid' );
		
		$map_width = $params->get ( 'map_width', 200 );
		$map_height = $params->get ( 'map_height', 300 );
		
		$map_draggable = $params->get ( 'map_draggable','0');
		$map_draggable = ($map_draggable) ? 'true' : 'false';
		$cursorDraggable = $params->get ( 'map_marker_draggable','0');
		$cursorDraggable = ($cursorDraggable) ? 'true' : 'false';
		 
		$scaleControl = ($params->get ( 'scale_control', '1' )) ? 'true' : 'false';
		$panControl = ($params->get ( 'pan_control', '1' )) ? 'true' : 'false';
		$map_bgcolor = $params->get ( "map_bgcolor", "#111518" );
		
		$mapTypeControl = ($params->get ( 'maptype_control', '1' )) ? 'true' : 'false';
		$scaleTypeControl = ($params->get ( 'scale_control', '1' )) ? 'true' : 'false';
		$module_id = $module->id;
		$weather = ($params->get ( 'show_weather', 1 )) ? 'true' : 'false';
		$doubleClickZoom = ($params->get ( 'map_doubleclickzoom', '0' )) ? 'true' : 'false';
		$scrollwheel = ($params->get ( 'map_scrollwheel', '0' )) ? 'true' : 'false';
		$zoomControl = ($params->get ( 'zoom_control','0' )) ? 'true' : 'false';
		$rotateControl = ($params->get ( 'rotate_control', '0' )) ? 'true' : 'false';
		$streetviewControl = ($params->get ( 'map_streetview', '0' )) ? 'true' : 'false';
		$zoomControlPosition = $params->get ( 'zoom_control_poisition', 'LEFT_CENTER' );
		$mapControlPosition = $params->get ( 'map_control_poisition', 'LEFT_CENTER' );
		$map_control_style = $params->get ( 'map_control_style', 'HORIZONTAL_BAR' );
		$map_control_style = strtoupper ( $map_control_style );
		// $selectedMode = $params->get ( 'mode_of_travel' );
		 
		?>
<script type="text/javascript">	 
		
		var myCenter=new google.maps.LatLng(<?php echo $latitude;?>,<?php echo $longitude;?>);
		function initialize() {				
		  var map = new google.maps.Map(document.getElementById('map-canvas'), {
			  	center				: 	myCenter,	
			  	zoom				:	<?php echo $zoom;?>,
				width				:	<?php echo $map_width;?>,
				height				:	<?php echo $map_height;?>,
				cavas_id			:	'jbgooglemap_canvas_id<?php echo $module_id;?>',
				scaleControl		:	<?php echo $scaleControl;?>,
				panControl			:	<?php echo $panControl;?>,		
				mapTypeControl  	: 	<?php echo $mapTypeControl;?>,			    
			    zoomControl			: <?php echo $zoomControl;?>,
			   	rotateControl		: <?php echo $rotateControl;?>,	
			    pane				: "floatPane" ,

				/* set zoom control options  */		   	 
			    zoomControlOptions	: {
			    		      style: google.maps.ZoomControlStyle.LARGE,
			    		      position: google.maps.ControlPosition.<?php echo $zoomControlPosition;?>
			    		    },
			   mapTypeControlOptions: {				   
			    		        style: google.maps.MapTypeControlStyle.<?php echo $map_control_style;?>,
			    		        position: google.maps.ControlPosition.<?php echo $mapControlPosition;?>,
			    		        mapTypeIds: [
			    		                     google.maps.MapTypeId.ROADMAP,
			    		                     google.maps.MapTypeId.TERRAIN,
			    		                     google.maps.MapTypeId.SATELLITE,
			    		                     google.maps.MapTypeId.HYBRID,			    		                     
			    		                   ]
			    		      },

			    styles 				: [
			                           {
			                               "featureType": "all",
			                               "elementType": "all",
			                               "stylers": [
			                                   {
			                                       "saturation": -10
			                                   } 
			                               ]
			                           }, { featureType: "water", stylers: [ { hue: "#F4B741"} ] },
			                           { featureType: "road", stylers: [ { hue: "#ff0000" } ] }
			                       ], 
				streetViewControl:<?php echo $streetviewControl;?>,
			   	streetViewControlOptions: {
			                           position: google.maps.ControlPosition.LEFT_TOP
			                       },  
				 			   
			    mapTypeId			:	 google.maps.MapTypeId.<?php echo strtoupper($mapType);?>,
			    backgroundColor 	:	'<?php echo $map_bgcolor;?>',
			    maxZoom				:	19,
			    minZoom				:	2,	  
			    animation			: google.maps.Animation.DROP, 		   
			    draggable			: <?php echo $map_draggable;?>,
			    weather 			:	<?php echo $weather;?>,
			    disableDoubleClickZoom: <?php echo $doubleClickZoom;?>,
			    scrollwheel    		: <?php echo $scrollwheel;?>,
			      
			  });

		  var coordInfoWindow = new google.maps.InfoWindow();
			var image = '<?php echo $markerIcon;?>';
			var marker = new google.maps.Marker({map: map,position: myCenter,icon: image,draggable: <?php echo $cursorDraggable;?>});
		  // Show tool tip on mouse over
		  google.maps.event.addListener(marker, 'mouseover', function () {
			  coordInfoWindow.setContent(createInfoWindowContent(myCenter, map.getZoom()));
			  coordInfoWindow.open(map, marker);        
		    }.bind(this)); 

         // show on mouse out
		google.maps.event.addListener(marker, 'mouseout', function () {
		    	coordInfoWindow.close();
		    }.bind(this));

		
		}
		var TILE_SIZE = 256;		
		function createInfoWindowContent(latLng, zoom) {
		  var scale = 1 << zoom;
		  var worldCoordinate = project(latLng);
		  var pixelCoordinate = new google.maps.Point(
		      Math.floor(worldCoordinate.x * scale),
		      Math.floor(worldCoordinate.y * scale));
		  var tileCoordinate = new google.maps.Point(
		      Math.floor(worldCoordinate.x * scale / TILE_SIZE),
		      Math.floor(worldCoordinate.y * scale / TILE_SIZE));
		  return [
		    '<?php echo $location_title;?><br/><?php echo $address;?>',		         
		  ].join('<br>');
		}


		//The mapping between latitude, longitude and pixels is defined by the web
		//mercator projection.
		function project(latLng) {
			var siny = Math.sin(latLng.lat() * Math.PI / 180);
				// Truncating to 0.9999 effectively limits latitude to 89.189. This is
				// about a third of a tile past the edge of the world tile.
				siny = Math.min(Math.max(siny, -0.9999), 0.9999);		
				return new google.maps.Point(
				   TILE_SIZE * (0.5 + latLng.lng() / 360),
				   TILE_SIZE * (0.5 - Math.log((1 + siny) / (1 - siny)) / (4 * Math.PI)));
		}

		function toggleBounce() {
			  if (marker.getAnimation() !== null) {
			    marker.setAnimation(null);
			  } else {
			    marker.setAnimation(google.maps.Animation.BOUNCE);
			  }
		}

		google.maps.event.addDomListener(window, 'load', initialize); 
		//init_map();
		jQuery('#jbgooglemap_canvas_id<?php echo $module_id;?>').find('.map-opener').on('click',function(){
			jQuery('#map-section').addClass