Codice PHP:
<?php $documento =& JFactory::getDocument(); $documento->addScript('http://code.google.com/apis/gears/gears_init.js'); $javascript =" var coordinate = null; function getLocale(){ if ( navigator ) { if ( navigator.userLanguage ) { return navigator.userLanguage.toLowerCase(); } else if ( navigator.language ) { return navigator.language.toLowerCase(); } else if ( navigator.browserLanguage ) { return navigator.browserLanguage.toLowerCase(); } else if ( navigator.systemLanguage ) { return navigator.systemLanguage.toLowerCase(); } } return \"unknown\"; } var locales = new Object(); locales[\"en-gb\"] = {lat:54.559322587438636, lng:-4.1748046875, location:\"United Kingdom\"}; locales[\"en-us\"] = {lat:38.41055825094609, lng:-100.37109375, location:\"USA\"}; // TODO - more locales function TryGoogleLoader(){ if (google.loader.ClientLocation != null) { var address = google.loader.ClientLocation.address; var yourLocation = address.city + \", \" + address.region + \", \" + address.country; document.getElementById(\"location\").innerHTML = \"Your location (using Google loader) is \" + yourLocation; var latLong = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude); //showMap(latLong, 12); coordinate = latLong; } else { // map locale to location var locale = getLocale(); if (locales[locale] != null) { var latLong = new google.maps.LatLng(locales[locale].lat, locales[locale].lng); document.getElementById(\"location\").innerHTML = \"Guessing your location based on your locale - \" + locales[locale].location; //showMap(latLong, 5); coordinate = latLong; } else { document.getElementById(\"location\").innerHTML = \"Your location can not be found - locale is \" + locale; } } } function TryGoogleGears(){ if (google.gears) { // Try Google Gears Geolocation var geo = google.gears.factory.create('beta.geolocation'); geo.getCurrentPosition(function(position) { var latLong = new google.maps.LatLng(position.latitude, position.longitude); document.getElementById(\"location\").innerHTML = \"Found location via Google Gears\"; //showMap(latLong, 15); coordinate = latLong; }, function() { TryGoogleLoader(); }); } else TryGoogleLoader(); } "; $documento->addScriptDeclaration($javascript); \\* @package: Sobi2 \\* =================================================== \\ * @author \\* Name: Sigrid & Radek Suski, Sigsiu.NET GmbH \\* Email: sobi[at]sigsiu.net \\......bla bla bla..... $config->getGoogleMaps(); $baseAddresse = $params->get('baseAddresse', 'http://maps.google.com'); $width = $params->get('width'); $height = $params->get('height'); $mapControl = $params->get('MapControl'); $mapTypeControl = $params->get('MapTypeControl'); $overviewMapControl = $params->get('OverviewMapControl',1); $doubleClickZoom = $params->get('DoubleClickZoom',1); $mapTypeOnStart = $params->get('MapTypeOnStart', 'G_NORMAL_MAP'); $centerPointLat = $params->get('centerPointLat',"0.0" ); $centerPointLat = str_replace(',','.',$centerPointLat ); $centerPointLong = $params->get('centerPointLong', "0.0" ); $centerPointLong = str_replace(',','.',$centerPointLong ); $mapsZoom = $params->get('MapsZoom', 1 ); $hybrid_label = $params->get('hybrid_label', "Labels"); $Automatic = $params->get('Automatic', 0); $showEmpty = $params->get('showEmpty', 1); $debugMode = $params->get('debugMode', 0); if (($catId > 1) && ($inSobi)) { //nur wenn in einer cat sonst net if( strstr( $catsCenterPoints, "\n" ) ) { $catsCenterPoints = explode( "\n", $catsCenterPoints ); } elseif( strstr( $catsCenterPoints, "\r" ) ) { $catsCenterPoints = explode( "\r", $catsCenterPoints ); } else { $catsCenterPoints = array($catsCenterPoints); } if( is_array( $catsCenterPoints ) && !empty( $catsCenterPoints ) ) { foreach ( $catsCenterPoints as $point ) { $point = trim( $point ); $point = explode( ":", $point ); if( trim( $point[0] ) == $catId ) { if( ( isset( $point[1] ) && is_numeric( $point[1] ) ) && isset( $point[2] ) && is_numeric( $point[2] ) ) { $centerPointLat = floatval( $point[1] ); $centerPointLong = floatval( $point[2] ); if( isset( $point[3] ) && is_numeric( $point[3] ) ) { $mapsZoom = intval( $point[3] ); } } break; } } } } if( !( is_numeric( $centerPointLat ) ) || !( is_numeric( $centerPointLong ) ) ) { $centerPointLat = "0.0"; $centerPointLong = "0.0"; } \\ ....bla bla bla... if(empty($sobiItems)) { //keine Einträge mit Koordinaten if (strlen($errormsg) && ($debugMode)) { showErrorMessage($errormsg); $errormsg = ''; } if (!$showEmpty) { return null; } } $map_api_version = $config->key("google_maps", "google_map_apiversion", "2"); $module_path = defined( 'JPATH_SITE' ) ? 'mod_sobi2gcat/' : null; echo "\n"; echo ""; echo "\n"; echo "<div class=\"sobi2gcat{$class}\">"; ?> <script type="text/javascript"> window.onDomReady = DomReady; function DomReady(func) { if(document.addEventListener) { document.addEventListener("DOMContentLoaded", func, false); } else { document.onreadystatechange = function() { readyState(func) } } } function readyState(func) { if(document.readyState == "complete") { func(); } } </script> <?php echo "\n\t "; echo "<script src=\"{$baseAddresse}/maps?file=api&v={$map_api_version}&key={$config->googleMapsApiKey}\" type=\"text/javascript\"></script>"; //if ($mapControl == 3) { // echo "<script src=\"{$config->liveSite}/modules/{$module_path}extlargemapcontrol.js\" type=\"text/javascript\"></script>"; //} echo "\n\t <script type=\"text/javascript\">"; echo "\n\t "; echo "//<![CDATA[ "; echo "\n\t\t "; echo "function loadSobiCatOverMap() {"; echo "\n\t\t\t "; echo "if ( GBrowserIsCompatible() ) {"; echo "\n\t\t\t\t "; echo "\n\t // try W3C standard approach"; echo "\n\t var geoTimeout = 10000;"; echo "\n\t var timeOuthandler = setTimeout(\"TryGoogleGears()\", geoTimeout);"; echo "\n\t if(navigator.geolocation) {"; echo "\n\t navigator.geolocation.getCurrentPosition(function(position) {"; echo "\n\t clearTimeout(timeOuthandler);"; echo "\n\t var latLong = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);"; echo "\n\t document.getElementById(\"location\").innerHTML = \"Found location via W3C standard\";"; echo "\n\t //showMap(latLong, 15);"; echo "\n\t coordinate = latLong;"; echo "\n\t }, function() {"; echo "\n\t // something went wrong, try Google Gears"; echo "\n\t clearTimeout(timeOuthandler);"; echo "\n\t TryGoogleGears();"; echo "\n\t }, {timeout:geoTimeout});"; echo "\n\t }"; echo "\n\t else"; echo "\n\t TryGoogleGears();"; echo "var SobiCatOverMap = new GMap2( document.getElementById(\"sobi2GcatOver\") );"; echo "\n\t\t\t\t "; //echo "SobiCatOverMap.setCenter( new GLatLng( {$centerPointLat}, {$centerPointLong} ), {$mapsZoom} );"; echo "SobiCatOverMap.setCenter( new GLatLng( coordinate ), {$mapsZoom} );"; \\ bla bla bla........ echo "\n\t\t\t\t "; echo "var MarkerPoint = new GLatLng({$sobiItem->latitude},{$sobiItem->longitude});"; echo "\n\t\t\t\t "; echo "SobiCatOverMap.addOverlay( createSobiMarker( MarkerPoint, '{$bubble}', {$itemCid} ) );"; echo "\n\t\t\t\t "; echo "MarkerBounds.extend(MarkerPoint);"; } if ($Automatic) { echo "\n\t\t\t\t "; echo "SobiCatOverMap.setCenter(MarkerBounds.getCenter());"; echo "\n\t\t\t\t "; $incZoom = 0; if (count($sobiItems) == 1) $incZoom = 2; echo "SobiCatOverMap.setZoom(SobiCatOverMap.getBoundsZoomLevel(MarkerBounds)-{$incZoom});"; } echo "\n\t\t\t "; echo "} "; echo "\n\t\t "; echo "} "; echo "\n\t\t "; echo "function createSobiMarker( point, html, sid ) {"; echo "\n\t\t\t "; if( $customMarker && file_exists( _SOBI_CMSROOT.DS.$customMarker ) ) { if( $useCatsCustomMarker ) { echo "SCustomMarkers = new Array();"; echo $jsImgArr; echo "\n\t\t\t "; } list( $mWidth, $mHeight ) = getimagesize( _SOBI_CMSROOT.DS.$customMarker ); $gxpoint = $mWidth / 2; $gypoint = $mHeight / 2; echo "var icon = new GIcon();"; echo "\n\t\t\t "; echo "icon.image = \"{$config->liveSite}/{$customMarker}\";"; echo "\n\t\t\t "; echo "icon.iconSize = new GSize( {$mWidth}, {$mHeight} );"; if( $markerShadow && file_exists( _SOBI_CMSROOT.DS.$markerShadow ) ) { list( $msWidth, $msHeight ) = getimagesize( _SOBI_CMSROOT.DS.$markerShadow ); echo "\n\t\t\t "; echo "icon.shadowSize = new GSize( {$msWidth}, {$msHeight} );"; echo "\n\t\t\t "; echo "icon.shadow = \"{$config->liveSite}/{$markerShadow}\";"; echo "\n\t\t\t "; } echo "\n\t\t\t "; echo "icon.iconAnchor = new GPoint( $offsetX, $offsetY );"; echo "\n\t\t\t "; echo "icon.infoWindowAnchor = new GPoint( {$gxpoint}, 5 );"; \\ bla bla bla.... echo "\n\t\t\t "; echo "var marker = new GMarker( point, icon );"; } else { echo "var marker = new GMarker( point );"; } echo "\n\t\t\t"; echo "GEvent.addListener(marker, 'click', function() {"; echo "\n\t\t\t\t"; echo "marker.openInfoWindowHtml('<div class=\"sobiCatOverBubble\">'+html+'</div>');"; echo "\n\t\t\t"; echo "});"; echo "\n\t\t\t"; echo "return marker;"; echo "\n\t\t"; echo "}"; echo "\n\t\t"; echo "DomReady(loadSobiCatOverMap);"; echo "\n\t"; echo "//]]>"; echo "\n\t"; echo "</script>"; echo "\n"; echo "\n\t "; echo "<div style=\"width: {$width}px; height:{$height}px\" id=\"sobi2GcatOver\" ></div>"; echo "\n"; echo "</div>"; echo "\n"; echo ""; echo "\n"; } else { return false; } error_reporting( $restoreErrorReporting ); ?>