Google Latitude PDF Print E-mail
Written by Mike Reumer   
Thursday, 20 May 2010 22:47

You can add google latitude to the map. Goto the page: http://www.google.com/latitude/apps/badge and set the correct settings and copy the public kml-feed as url for the plugin. Best is to add centerlat/lon and zoom level to prevent to see grey tiles or use version 2.12o with correction on automatic zoom.

For example:

{mosmap kml='http://www.google.com/latitude/apps/badge/api?user=xxxxxxxxxx&type=kml'|corzoom='-4'}

Other option is to add your latitudeid as a parameter for better security:

{mosmap latitudeid='xxxxxx'|latitudedesc='1'|latitudecoord='1'}

Extra parameters are:

  • latitudedesc - Show latitude description in infowindow
  • latitudecoord - Show coordinates in infowindow

You can write an own php program to show a page and incorporate this page in Joomla by a wrapper or use the code in a plugin that can execute php. Thanks to Kelly Courtney/

The code is:

<?php 
function file_get_contents_curl($url)

  {

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_HEADER, 0);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.

  curl_setopt($ch, CURLOPT_URL, $url);

  $data = curl_exec($ch);

  curl_close($ch);

  return $data;

  }


// No Caching
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

// Refreshes pages after 60 seconds
header("Refresh: 60;");

// Get Data from Google (must be allowed in php.ini: allow_url_fopen = 1 or allow_url_fopen = On)
// Replace XXXX with your personal user id from Google.

$datastring = file_get_contents('http://www.google.de/latitude/apps/badge/api?user=XXXXXXXX&type=kml');
// Or use curl:
$datastring = file_get_contents_curl('http://www.google.de/latitude/apps/badge/api?user=XXXXXXXX&type=kml');


// String Operations
// Find String in between...
function get_string_between($string, $start, $end)
{
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}

// Get Coordinates
$coordinates = get_string_between($datastring, "<coordinates>", "</coordinates>");

// Extract coordinates as they are separated with a comma
$token = strtok($coordinates, ",");

while ($token != false)
{
if ($token != Null) {$array[] = $token;} else {$array[] = ' ';}
$token = strtok(",");
}
// Print the GPS coordinates on the screen
// echo "Longitude: ".$array[0]." Latitude: ".$array[1];

// Small table for the coordinates (my style):
$tabelle = "<table border=\"0\"><tbody><tr><td>GPS: </td><td>Latitude </td><td>Longitude</td></tr><tr><td> </td><td>".$array[1]."</td><td>".$array[0]."</td></tr></tbody></table>";

// Get the description of the KML-File
$description = get_string_between($datastring, "<description>", " http://www.google.com/latitude/apps/badge</description>");

// Alternative: $description = str_replace(' http://www.google.com/latitude/apps/badge', '', $description);

// Combine the strings for the textfield
$string_neu = "<div style=\"width:220px; height:90px;\"><b>Name</b><br />".$description."<br />".$tabelle."</div>";

// Replace all " within the string with HTML-character
$string_neu = str_replace('"','&quot;',$string_neu);

// User Name (can be the Joomla User Name)
echo "<b>Hello Name, </b>";

// Display the map
echo "<p>{mosmap width='650'|height='525'|zoom='16'|align='center'|mapType='Hybrid'|icon='http://yourwebsite/images/stories/latitude_marker.png'|iconwidth='30'|iconheight='38'|text='".$string_neu."'|zoomWheel='1'|zoomtype='3D-largeSV'|showMaptype='1'|overview='1'|tooltip='GPS-Daten'|marker='0'|lat='".$array[1]."'|lon='".$array[0]."'}</p>";

?>

This hides the latitude id from the visitors of the website so better privacy.

You can change the icon by using the custom icon configuration or params of the plugin.

Last Updated on Friday, 25 November 2011 20:22
 

Advertisement