Zum Inhalt springen

mh_branchenbuch und Googlemaps DRINGEND!

Erstellt am 8. Januar 2013 · 9 Antworten · letzte Antwort am 9. Januar 2013

Tags: Frage

romihue ·

Hallo Leute

Hat irgendjemand mh_branchenbuch mit googlemaps laufen und funktioniert? Ich hab die extention und funktioniert soweit, aber googlemaps erscheint nicht auf der Detailseite.
Wird dies extension ueberhaupt noch gepflegt? Im seinem Forum tut sich nichts und keine Antwort vom Entwickler. Ich hab die extension installiert, aber ich weiss nicht welche extension fuer googlemaps benutzt werden muss. (kann man das irgendwo in eine php aendern?) Bei mir erscheint gar nichts. Hatte lumogooglemaps, cbgooglempas und go_maps_ext. Bei keiner erscheint googlemaps auf der Anbieterseite(Detailseite)
Ich finde nichts im Forum von mh_branchenbuch oder anderen Foren und brauche dringend etwas Hilfe oder wenigstens einen Tip.:o

Vielen Dank Romihue

Norman2k ·

Ich kenne die Extension nicht aber ein kurzer Blick in die Doku/den Source zeigt, dass man in den Konstanten einen API-Key für GoogleMaps hinterlegen muss:

#cat=Yellow Page (mh_branchenbuch) - Overview//j; type=string; label=API-Key for GoogleMap:You need a API-Key to use Google-Maps!
  map_api
romihue ·
Norman2k schrieb

Ich kenne die Extension nicht aber ein kurzer Blick in die Doku/den Source zeigt, dass man in den Konstanten einen API-Key für GoogleMaps hinterlegen muss:

#cat=Yellow Page (mh_branchenbuch) - Overview//j; type=string; label=API-Key for GoogleMap:You need a API-Key to use Google-Maps!
  map_api

Hallo Norman2k,

Danke fuers antworten, aber da sit das problem. Googlemaps hat ja keine apikeys mehr und bis jetzt hab ich nur eine extension mit dem neuen V3 Javascript gefunden, aber diese funktioniert scheinbar nicht mit mh_branchenbuch. Schade das der Entwickler nicht auf anfragen antwortet.

Norman2k ·

https://developers.google.com/maps/signup

Google Maps JavaScript API v2

Note: The Google Maps Javascript API Version 2 has been officially deprecated as of May 19, 2010. The v2 API will continue to work as per our deprecation policy, but we encourage you to migrate your code to version 3 of the Maps Javascript API.

The APIs Console can be used to generate new keys for your existing Maps JavaScript API v2 applications. Learn how to use an APIs Console key.

romihue ·
Norman2k schrieb

https://developers.google.com/maps/signup

Google Maps JavaScript API v2

Note: The Google Maps Javascript API Version 2 has been officially deprecated as of May 19, 2010. The v2 API will continue to work as per our deprecation policy, but we encourage you to migrate your code to version 3 of the Maps Javascript API.

The APIs Console can be used to generate new keys for your existing Maps JavaScript API v2 applications. Learn how to use an APIs Console key.

Fein, hab ich gelesen (Obwohl ich es einigermassen umstaendlich beschrieben finde) aber trotzdem weiss ich noch nicht welche extension ich benutzen kann fuer mh_brnachenbuch.😢

Norman2k ·

Du benötigst keine extra Extension, die Maps-Funktion ist bereits in der Extension integriert (class.tx_mhbranchenbuch_pi1.php, function initMap).

romihue ·
Norman2k schrieb

Du benötigst keine extra Extension, die Maps-Funktion ist bereits in der Extension integriert (class.tx_mhbranchenbuch_pi1.php, function initMap).

Das heisst das ich die funktion abaendern muss damit es ohne apikey funktioniert?

Norman2k ·

Ja natürlich musst du die Funktion anpassen wenn du die GoogleMaps API v3 verwenden willst. Oder wie oben geschrieben, holst du dir nen API-Key für v2

romihue ·
Norman2k schrieb

Ja natürlich musst du die Funktion anpassen wenn du die GoogleMaps API v3 verwenden willst. Oder wie oben geschrieben, holst du dir nen API-Key für v2

Hi Norman2k,

Am besten glerich API v3, weil ab Mai funktioniert v2 nicht mehr. Bin kein Profi in PHP. Hab den Code in der class.tx_mhbranchenbuch_p1.php wie folgt laut google geaendert:
von:

$output .= '
      <script type="text/javascript">
      document.write(\'<sc\'+\'ript src="http://maps.google.com/maps?file=api&v=2&key=' . $api . '" type="text/javascript"></scr\'+\'ipt>\');
      function mapload() {
      	 if (GBrowserIsCompatible()) {
      		var gmap = new GMap2(document.getElementById("mh_branchenbuch_map"), {mapTypes:[G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP]});
      		gmap.addControl(new GSmallMapControl());
      		gmap.addControl(new GMapTypeControl());
      		gmap.setCenter(new GLatLng(' . $lat . ',' . $lng . '),' . $zoom . ');
      		' . $marker . '
      	 }
      }
      
      function createMarker(point, mtext) {
      	var marker = new GMarker(point);
      	GEvent.addListener(marker, "click", function() {
      		marker.openInfoWindowHtml( mtext );
      	});
      	return marker;
      }
      window.setTimeout(mapload,1000);
      </script>';

auf

$output .= '
      <script type="text/javascript">
      document.write(\'<sc\'+\'ript src="http://maps.google.com/maps/api/js?" type="text/javascript"></scr\'+\'ipt>\');
      function mapload() {
      	 if (GBrowserIsCompatible()) {
      		var gmap = new GMap2(document.getElementById("mh_branchenbuch_map"), {mapTypes:[G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP]});
      		gmap.addControl(new GSmallMapControl());
      		gmap.addControl(new GMapTypeControl());
      		gmap.setCenter(new GLatLng(' . $lat . ',' . $lng . '),' . $zoom . ');
      		' . $marker . '
      	 }
      }
      
      function createMarker(point, mtext) {
      	var marker = new GMarker(point);
      	GEvent.addListener(marker, "click", function() {
      		marker.openInfoWindowHtml( mtext );
      	});
      	return marker;
      }
      window.setTimeout(mapload,1000);
      </script>';
      
      $markerArray['###GENERATED_CODE###'] = $output;
      
      return $this->cObj->substituteMarkerArrayCached($template,$markerArray,array(),$wrappedSubpartArray);
      
    } else {
      return 'Error, no API-Key found!';
    }
  }

Funzt aber nicht. Kannst Du mir sagen was da falsch ist?
Waere super nett!😃

Gruss romihue

romihue ·

Obwohl ich einen neuen api key erstellt habe bekomme ich immer diese Nachricht:

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v2 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: http://code.google.com/apis/maps/documentation/javascript/v2/introduction.html#Obtaining_Key

jetzt wollte ich die extension (mh_branchenbuch/class.tx_mhbranchenbuch_p1.php ) im Bereich googlemap umschreiben (vom Entwickler hab ich ja keine Antwort bekommen...) aber da ich nur den Teil kenne, ist wohl was falsch. Wenn ich das hochlade, erscheint nur ne weisse Seite. Wahrscheinlich eine endlosschleife. Bin halt kein PHP Profi. Ich kopier mal das Original (funktioniert bis auf die Fehlermeldung obne) und das geaenderte auf v3, das leider nicht funktioniert. Vieleicht hat ja ein Profi hier etwas mitleid und stoesst meine Amateurnase auf den wahrscheinlichen Anfaengerfehler:o

Version v2:

function initMap($lat, $lng, $lid = FALSE, $bid = FALSE, $oid = FALSE, $uid = FALSE) {
    
    $template = $this->cObj->getSubpart($this->template,"###MAPCODE###");
    
    $api                  = $this->map_api;
    $output               = ''; #init
    $markerArray          = array(); #init
    $wrappedSubpartArray  = array(); #init
    
    $WHERE_CLAUSE = ''; #init
    if($bid) { $WHERE_CLAUSE .= 'f.`bundesland` = ' . intval($bid); $zoom = $this->map_zoom1; }
    if($lid) { $WHERE_CLAUSE .= ' f.`landkreis` = ' . intval($lid); $zoom = $this->map_zoom2; }
    if($oid) { $WHERE_CLAUSE .= ' f.`ort` = ' . intval($oid); $zoom = $this->map_zoom3; }
    if($uid) { $WHERE_CLAUSE .= ' f.`uid` = ' . intval($uid); $zoom = $this->map_zoom4; }
    
    if($api) {
               
      $sql = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,"
        SELECT 
          f.*,
          o.zip AS o_zip,
          o.name AS o_city
        FROM  
          `" . $this->dbTable1 . "` f
          LEFT JOIN " . $this->dbTable5 . " o ON o.uid = f.ort
          LEFT JOIN " . $this->dbTable2 . " k ON k.uid = f.kategorie
        WHERE 
          " . $WHERE_CLAUSE . "
        AND
          f.`map_lat` != ''
        AND
          f.`map_lng` != ''
        AND
          f.`deleted` = 0
        AND 
          f.`hidden` = 0
      ");
      
      $marker = ''; #init
      if($GLOBALS['TYPO3_DB']->sql_num_rows($sql)) {
        while($row = mysql_fetch_array($sql)) {
          $marker_content = $this->cObj->getTypoLink($row['firma'],$row['link'],'', $this->conf['linkTarget']);
          
          if($row['forename'] != "" && $row['lastname'] != "") {
            $marker_content .= '<br />' . $row['forename'] . ' ' . $row['lastname'];
          }

          $adresse = $row['adresse'];
          $adresse = preg_replace('/\r\n|\n|\r/', '<br />', $adresse);
          
          $marker_content .= '<br />' . $adresse;
          
          $zip  = $row['zip'] != '' ? $row['zip'] : $row['o_zip'];
          $city = $row['city'] != '' ? $row['city'] : $row['o_city'];
          $marker_content .= '<br />' . $zip . ' ' . $city;
          
          $marker_content .= '<br /><br />' .$this->cObj->stdWrap($row['telefon'],$this->conf['tel_stdWrap.']);
        	$marker_content .= '<br />' .$this->cObj->stdWrap($row['fax'],$this->conf['fax_stdWrap.']);
        	
        	if($this->map_showImage == 1) {
          	$file                         = ($row['bild'] == false) ? $this->conf['noImage'] : 'uploads/tx_mhbranchenbuch/'. $row['bild'];
            $imgTSConfig                  = Array();
            $imgTSConfig['file']          = $file;
            $imgTSConfig['file.']['maxW'] = $this->imgMaxWidth;
            $imgTSConfig['file.']['maxH'] = $this->imgMaxHeight;
            $imgTSConfig['altText']       = $row['firma'];
            $imgTSConfig['titleText']     = $row['firma'];
            $imgTSConfig['params']        = $this->imageParams;
            
            if(strlen($row['detail'])>0) {
              $marker_content .= '<br /><br />' .$this->pi_linkTP($this->cObj->IMAGE($imgTSConfig),array($this->prefixId.'[detail]'=> $row['uid']),1,$this->single_pid);
            } else {
              if(isset($row['link'])) {
                $marker_content .= '<br /><br />' .$this->cObj->getTypoLink($this->cObj->IMAGE($imgTSConfig),$row['link'],'', $this->conf['linkTarget']);
              } else {  
                $marker_content .= '<br /><br />' .$this->cObj->IMAGE($imgTSConfig);
              }
            }
          }
          
          $marker .= "gmap.addOverlay(createMarker( new GLatLng(" . $row['map_lat'] . "," . $row['map_lng'] . "), '<p class=\"mh_branchenbuch_mapcon\">" . $marker_content . "</p>'));\n";
        }
      }

      $output .= '
      <script type="text/javascript">
      document.write(\'<sc\'+\'ript src="http://maps.google.com/maps?file=api&v=2&key=' . $api . '" type="text/javascript"></scr\'+\'ipt>\');
      function mapload() {
      	 if (GBrowserIsCompatible()) {
      		var gmap = new GMap2(document.getElementById("mh_branchenbuch_map"), {mapTypes:[G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP]});
      		gmap.addControl(new GSmallMapControl());
      		gmap.addControl(new GMapTypeControl());
      		gmap.setCenter(new GLatLng(' . $lat . ',' . $lng . '),' . $zoom . ');
      		' . $marker . '
      	 }
      }
      
      function createMarker(point, mtext) {
      	var marker = new GMarker(point);
      	GEvent.addListener(marker, "click", function() {
      		marker.openInfoWindowHtml( mtext );
      	});
      	return marker;
      }
      window.setTimeout(mapload,1000);
      </script>';
      
      $markerArray['###GENERATED_CODE###'] = $output;
      
      return $this->cObj->substituteMarkerArrayCached($template,$markerArray,array(),$wrappedSubpartArray);
      
    } else {
      return 'Error, no API-Key found!';
    }
  }

und Version V3 (funktioniert leider noch nicht#angry#

function initMap($lat, $lng, $lid = FALSE, $bid = FALSE, $oid = FALSE, $uid = FALSE) {
    
    $template = $this->cObj->getSubpart($this->template,"###MAPCODE###");
    
    $api                  = $this->map_api;
    $output               = ''; #init
    $markerArray          = array(); #init
    $wrappedSubpartArray  = array(); #init
    
    $WHERE_CLAUSE = ''; #init
    if($bid) { $WHERE_CLAUSE .= 'f.`bundesland` = ' . intval($bid); $zoom = $this->map_zoom1; }
    if($lid) { $WHERE_CLAUSE .= ' f.`landkreis` = ' . intval($lid); $zoom = $this->map_zoom2; }
    if($oid) { $WHERE_CLAUSE .= ' f.`ort` = ' . intval($oid); $zoom = $this->map_zoom3; }
    if($uid) { $WHERE_CLAUSE .= ' f.`uid` = ' . intval($uid); $zoom = $this->map_zoom4; }
    
    if($api) {
               
      $sql = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,"
        SELECT 
          f.*,
          o.zip AS o_zip,
          o.name AS o_city
        FROM  
          `" . $this->dbTable1 . "` f
          LEFT JOIN " . $this->dbTable5 . " o ON o.uid = f.ort
          LEFT JOIN " . $this->dbTable2 . " k ON k.uid = f.kategorie
        WHERE 
          " . $WHERE_CLAUSE . "
        AND
          f.`map_lat` != ''
        AND
          f.`map_lng` != ''
        AND
          f.`deleted` = 0
        AND 
          f.`hidden` = 0
      ");
      
      $marker = ''; #init
      if($GLOBALS['TYPO3_DB']->sql_num_rows($sql)) {
        while($row = mysql_fetch_array($sql)) {
          $marker_content = $this->cObj->getTypoLink($row['firma'],$row['link'],'', $this->conf['linkTarget']);
          
          if($row['forename'] != "" && $row['lastname'] != "") {
            $marker_content .= '<br />' . $row['forename'] . ' ' . $row['lastname'];
          }

          $adresse = $row['adresse'];
          $adresse = preg_replace('/\r\n|\n|\r/', '<br />', $adresse);
          
          $marker_content .= '<br />' . $adresse;
          
          $zip  = $row['zip'] != '' ? $row['zip'] : $row['o_zip'];
          $city = $row['city'] != '' ? $row['city'] : $row['o_city'];
          $marker_content .= '<br />' . $zip . ' ' . $city;
          
          $marker_content .= '<br /><br />' .$this->cObj->stdWrap($row['telefon'],$this->conf['tel_stdWrap.']);
        	$marker_content .= '<br />' .$this->cObj->stdWrap($row['fax'],$this->conf['fax_stdWrap.']);
        	
        	if($this->map_showImage == 1) {
          	$file                         = ($row['bild'] == false) ? $this->conf['noImage'] : 'uploads/tx_mhbranchenbuch/'. $row['bild'];
            $imgTSConfig                  = Array();
            $imgTSConfig['file']          = $file;
            $imgTSConfig['file.']['maxW'] = $this->imgMaxWidth;
            $imgTSConfig['file.']['maxH'] = $this->imgMaxHeight;
            $imgTSConfig['altText']       = $row['firma'];
            $imgTSConfig['titleText']     = $row['firma'];
            $imgTSConfig['params']        = $this->imageParams;
            
            if(strlen($row['detail'])>0) {
              $marker_content .= '<br /><br />' .$this->pi_linkTP($this->cObj->IMAGE($imgTSConfig),array($this->prefixId.'[detail]'=> $row['uid']),1,$this->single_pid);
            } else {
              if(isset($row['link'])) {
                $marker_content .= '<br /><br />' .$this->cObj->getTypoLink($this->cObj->IMAGE($imgTSConfig),$row['link'],'', $this->conf['linkTarget']);
              } else {  
                $marker_content .= '<br /><br />' .$this->cObj->IMAGE($imgTSConfig);
              }
            }
          }
          
          $marker .= "google.maps.addOverlay(createMarker( new GLatLng(" . $row['map_lat'] . "," . $row['map_lng'] . "), '<p class=\"mh_branchenbuch_mapcon\">" . $marker_content . "</p>'));\n";
        }
      }

      $output .= '
      <script type="text/javascript">
      document.write(\'<sc\'+\'ript src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></scr\'+\'ipt>\');
      function mapload() {
      	 
      		var latlng = new google.maps.LatLng(' .$lat . ',' . $lng . ',' . $marker . ')

      		var myOptions = {

      		zoom (' . $zoom . '),
      		center: latlng
      		mapTypeId: google.maps.MapTypeId.ROADMAP),
      		};
      		
      		map = new google.maps.Map(document.getElementById("mh_branchenbuch_map") myOptions );      		
      	 	
      }
      
      function createMarker(position, mtext) {
      	var myLatLng = new google.maps.LatLng(loc['$lat '], loc['$lng']);
		var marker = new google.maps.Marker({
    	position: myLatLng,
    	map: map,
    	shadow: shadow,
    	icon: image
		});
		marker.setMap(map);      	
      	
      	google.maps.addListener(marker, "click", function() {
      		marker.openInfoWindowHtml( mtext );
      	});
      	return marker;
      }
      window.setTimeout(mapload,1000);
      </script>';
      
      $markerArray['###GENERATED_CODE###'] = $output;
      
      return $this->cObj->substituteMarkerArrayCached($template,$markerArray,array(),$wrappedSubpartArray);
      
    } else {
      return 'Error, no API-Key found!';
    }
  }