Page 1 of 1

Problem whit google map

Posted: 11 Aug 2010, 18:05
by wolkmx
Hi there i was changing my phoca gallery, i want to change the geotagin option, originally the google map whit the category view, only show a default marker in the position that the owner define.

So i want to display in the map, all the thumbnails small of the photos of the actual category.

So i made before a module like this and works, i copy and paste my code to the default_geotagging.php file and here start the problems jeje.

So the map is create, the markers too, the map show in the tab of geotagging, but shows bad, the possition is wrong, i was searching the problem, but i can't find it , i try to change only the code of the original file and not override all, but the problem is the same.

I think that is a problem of some <div> or css, but i don't have idea.

So you can check it here
http://latino23.com/index.php?option=co ... a&Itemid=9

if you open the web whit IE, you can see all the map, but is not correct, because the map is not center in the long/lat that i set in the constructor (i think that always is a problem whit IE).

But if you open it whit all the others browsers you can see the problem.

Re: Problem whit google map

Posted: 12 Aug 2010, 09:45
by Jan
Hi, I think this is more CSS or HTML or JS question than some question on Phoca Gallery :-( In your code you have some errors - see the site, the code is displayed on the site too, which is wrong so you need to check it and try to set correct CSS, check the width too.

(but it is really difficult to add some advices to something what I don't know - your modifications :-( so my advices can be wrong :-( )

Jan

Re: Problem whit google map

Posted: 12 Aug 2010, 15:59
by wolkmx
Hi Jan thanks, the change that i did is to delete all the code from the file: default_geotagging.php, and writte some like this:

Code: Select all


<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<?php 

$nume = 30;
$ancho =600;
$alto = 200;
$zoom = 3;
                
                //Make the sql query to obtain all the photos from the current category
		$db = &JFactory::getDBO();
		$consulta = "SELECT a.* FROM #__phocagallery AS a LEFT JOIN #__phocagallery_img_votes AS v ON a.id = v.imgid WHERE a.catid = ".array_shift(explode(':',$this->category->slug,2))." GROUP BY a.id";
		$db->setQuery($consulta);
		$row= $db->loadRowList();

		$cont=0;
		
                //Save all the names and construct the addres of each thumbnail small photo

		for($n=0;$n<$nume;$n++){
		
			//obtener posicion de la ultima / save the position of the last slash (/)
			$posicion = strrpos($row[$n][5], "/");//filename
			//echo $posicion;
			
			//direccion Imagen Completa
			$direccC[$cont]="http://".$_SERVER['HTTP_HOST']."/images/phocagallery/".$row[$n][5];
			
			//miniatura.

			$direcc[$cont]="http://".$_SERVER['HTTP_HOST'].'/images/phocagallery/'.substr($row[$n][5], 0,$posicion)."/thumbs/phoca_thumb_s_".substr($row[$n][5], $posicion+1);
			
			
			$direccM[$cont]="http://".$_SERVER['HTTP_HOST'].'/images/phocagallery/'.substr($row[$n][5], 0,$posicion)."/thumbs/phoca_thumb_m_".substr($row[$n][5], $posicion+1);
			
                       //Save the long, latitude, title and description of each photo.

			$long[$cont]=$row[$n][10];//longitud
			$lati[$cont]=$row[$n][9];//latitude
			$titulo[$cont]=$row[$n][3];//title
			$descrip[$cont]=$row[$n][6];//description
			
			$cont++;
	}
		
/*Initialize the google map whit some default values*/
?>	

<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(12.434431,-78.427738);
    var myOptions = {
      zoom: <?php echo $zoom;?>,
      center: latlng, disableDefaultUI: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
		

<?php
/*create some variable in javascript 30 by default but if the value $row[$i][5]="" don create, its means that only create variables whit a true value, so if the gallery have only 2 photos, will be create only 2 variables. */
 for ($i=0; $i<$nume; $i++)
  {
	  if($row[$i][5]!=""){
	?>	
  
  var image<?PHP echo $i?> = '<?PHP echo $direcc[$i]?>';
  var image<?PHP echo $i?>m = '<?PHP echo $direccM[$i]?>';
  
 
 <?php 
/*Check if the image have long and lat, if the image don´t have the code create aleatory validate values else the code recovery the original values, all this to create the marker.*/
	if($long[$i]==""){
	
	$aleatoriolati[$i]=rand(-89, 89);
	$aleatoriolong[$i]=rand(-179, 179);
	
	}
	else{
	$aleatoriolong[$i]=$long[$i];
	$aleatoriolati[$i]=$lati[$i];
	}
 }
 }

/*So this code create the marker variable in javascript code and check the same posibility of empty value, add a pop up window event whit some info of the same photo, and the listening to each marker*/
for ($i=0; $i<$nume; $i++)
  {
	   if($row[$i][5]!=""){
	?>		
 var latlng<?php echo $i; ?> = new google.maps.LatLng(<?php echo $aleatoriolati[$i];?>,<?php echo $aleatoriolong[$i];?>);
  	var marker<?php echo $i; ?>= new google.maps.Marker({
     position: latlng<?php echo $i; ?>, 
     map: map, 
     title:"<?php echo $titulo[$i]; ?>",
	 icon: image<?php echo $i; ?>
	 }); 
	 
	 var contentString<?php echo $i; ?> = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<div id="bodyContent">'+
    '<?php echo $descrip[$i]; ?>'+'<a href="#" onclick="window.open(\'<?php echo $direccC[$i]; ?>\',\'Nueva Ventana\',\'width=800, height=600\')"><img src="'+image<?php echo $i; ?>m+'" /></a>'+
    '</div>'+
    '</div>';

		
var infowindow<?php echo $i; ?> = new google.maps.InfoWindow({
    content: contentString<?php echo $i; ?>,
	maxWidth: 350
});
 
 google.maps.event.addListener(marker<?php echo $i; ?>, 'click', function() {
  infowindow<?php echo $i;?> .open(map,marker<?php echo $i; ?>);
});
 
<?php
 }}
?>	

	
	}
	 google.maps.event.addDomListener(window, 'load', initialize);

</script><div style="width:600px; height:300px" align="center" >
<div id="map_canvas" style="height:100%"></div></div>

I think that like you say, is a problem of some width, i don't know why, i think that could be some div, that originally you create in this code, but i missing create or close it, i try whit no width default value but the problem still.

So let me know if i need to put more info, or if somebody want to check it to add this modification to his own phocagallery, of course the code could be upgrade, but for now i only want to display propertly the map.

Thanks.

Re: Problem whit google map

Posted: 12 Aug 2010, 16:53
by wolkmx
Finally i decide to modify the file called default.php in \components\com_phocagallery\views\category\tmpl

comment the line 560 to 569

and add at the end, my code, so now it works but not in the tab, so if somebody fixed it to work in the tab, please post it, of if somebody want to use the code, use it, only add to your code that i made the original change.

Re: Problem whit google map

Posted: 12 Aug 2010, 22:08
by wolkmx
So anybody know what file i need to modify to add 2 fields, so i add the map, so i have active the option which the users can upload photos, so they upload the photo, but i want to add the posibility to add the latitude and longitude field, i modify the file called defaultupload.php and now i can display the field and of course i add the event to the google map so if the user clic in the map automatically the values of latitude and longitude writte in the fields, so i want to save this values, but i can't find what file i need to modify, i think that only need to add the declaration of this values and change the sql query or the constructor.

Can somebody help me?

Re: Problem whit google map

Posted: 16 Aug 2010, 20:37
by Jan
Hi, field values from frontend are stored in module, depends on where you add the values

category:
components\com_phocagallery\models\category.php
UCP
components\com_phocagallery\models\user.php

Jan

Re: Problem whit google map

Posted: 16 Aug 2010, 21:12
by wolkmx
Thanks a lot Jan, i modify the UCP so i will check the user.php file to modify, but i have other quesion, I´m not sure about the file, the only think that i need is modify the part of code where the data from the UCP are cacht and save it in the DB, if i see the file components\com_phocagallery\models\user.php, i need start to add code near to the line 860?.

I ask again because im not sure about how you cacht the info from the form and save in the database.

So i think that i need to modify other file?, i think that always the sql sentences are in one file and in other file is the call of these method.

Re: Problem whit google map

Posted: 16 Aug 2010, 22:20
by Jan
Hi, maybe you should see some guide on Joomla! org site. In fact all the files are used (MVC pattern - model load the data from database, View display them in view.html.php and then in template and Controller get the information where to redirect)

So the controller get information from the form but it sends it to model where the sql query will be run and then if success or error, it will be sent back to controller which redirect the site with message.

Jan

Solved

Posted: 17 Aug 2010, 17:57
by wolkmx
Thanks a Jan, imperialWicket help me too so, this was confused, because i was sure that all was in the User Control Panel, so the file could be user.php, i other question imperialWicket wrotte about the user.php in the controller section, so after try a lot of changes jeje, the correct file was the category.php but in the controller section like you wrotte.

Finally i can save the lat and long in the user panel (but this user panel is displaying in the category view, not in a specify link), in the tab upload.

the lines that i add was only:

Code: Select all

          $post['longitude']      = JRequest::getVar( 'lonbox', '', 'post', 'string', 0 );//agregado
          $post['latitude']      = JRequest::getVar( 'latbox', '', 'post', 'string', 0 );//agregado

Thanks again.