RSS
Home
Welcome, Guest
Please Login or Register.    Lost Password?

Changing google api V2 to the new google api V3
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Changing google api V2 to the new google api V3
#9314
Changing google api V2 to the new google api V3 2 Years ago Karma: 0
Here is some of the conversion to use google api V3 instead of the V2 that is currently used in the Com-property component. There are still quite a few locations in the component that reference old google V2 api code which I would like to upgrade if I new what the code was actually for.

However, for the map display here's what I've done so far and it seems to work correctly.

The changes that were made to make this work with the existing application are:

\components\com_properties\controller.php:

Do a search for 'google' in the file and you'll find the location. (approx line 271) Replace the old function load() code and the old google maps javascript reference with the following:

Code:

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

function initialize() {
  var myLatlng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
  var myOptions = {
    zoom: <?php echo $distancia;?>,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
 var map = new google.maps.Map(document.getElementById("map"), myOptions);
  
 var image = "<?php echo JURI::base();?>components/com_properties/includes/img/house.png";
 var myLatLng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
 var houseMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
  });

var contentString = '<?php echo $myHtml;?>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

google.maps.event.addListener(houseMarker, 'click', function() {   
infowindow.open(map,houseMarker); 
});

}  
 
    //]]>
    </script> 
  </head> 
<body onload="initialize()" style="width: 750px; height: 495px;"> 



\components\com_properties\views\templates\details.php:

Do a search for 'google' in the file and you'll find the location. (approx line 905) Replace the old function loadmap code and the old google maps javascript reference with the following:

Code:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
 
 <script type="text/javascript"> 
  function loadmap() { 
      var myLatlng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
  var myOptions = {
    zoom: <?php echo $distancia;?>,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
 var map = new google.maps.Map(document.getElementById("map"), myOptions);
  
 var image = "<?php echo JURI::base();?>components/com_properties/includes/img/house.png";
 var myLatLng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
 var houseMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
  });
    }
</script> 



\components\com_properties\views\templates\details1.php:

Do a search for 'google' in the file and you'll find the location. (approx line 907) Replace the old function loadmap code and the old google maps javascript reference with the following:

Code:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
 
 <script type="text/javascript"> 
  function loadmap() { 
      var myLatlng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
  var myOptions = {
    zoom: <?php echo $distancia;?>,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
 var map = new google.maps.Map(document.getElementById("map"), myOptions);
  
 var image = "<?php echo JURI::base();?>components/com_properties/includes/img/house.png";
 var myLatLng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
 var houseMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
  });
    }
</script> 



\components\com_properties\views\templates\details2.php:

Do a search for 'google' in the file and you'll find the location. (approx line 756) Replace the old function loadmap code and the old google maps javascript reference with the following:

Code:

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

 <script type="text/javascript">
 function loadmap() {
 var myLatlng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
 var myOptions = {
 zoom: <?php echo $distancia;?>,
 center: myLatlng,
 mapTypeId: google.maps.MapTypeId.ROADMAP
 }
 var map = new google.maps.Map(document.getElementById("map"), myOptions);

 var myLatLng = new google.maps.LatLng(<?php echo $lat;?>, <?php echo $lng;?>);
 var marker = new google.maps.Marker({
 position: myLatLng,
 map: map
 });
 }
 </script>

Nemesis
Senior Boarder
Posts: 48
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2011/04/25 17:01 By Nemesis.
The administrator has disabled public write access.
 
#9803
Re: Changing google api V2 to the new google api V3 1 Year, 2 Months ago Karma: 0
hello
did you write the changes, but did not work. Is there a different way?
databil
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1