Hallo,
nachdem ich eine Webseite auf einen anderen Hoster umgezogen habe, funktionieren die Google Maps nicht mehr richtig. Wie ich herausgefunden habe, liegt das an einem API-Key. Ich habe bereits auch einen generiert, aber ich bekomme die Maps einfach nicht zum Laufen.
Es geht um folgende Seite: beta.tsggiessenwieseck.de
Folgender Code wird für die Maps verwendet:
PHP-Code:
<div class="info-map <?php echo $this->class ?>"<?php echo $this->cssID ?>>
<div class="info-map-gmap"></div>
<script>
(function() {
var mapElement = document.querySelectorAll && document.querySelectorAll('.info-map-gmap');
if (!mapElement || !mapElement.length) {
return;
}
mapElement = mapElement[mapElement.length - 1];
window.initializeGoogleMap_<?php echo $this->id ?> = function() {
var style = <?php
$style = array();
if ($this->hue) {
$style[] = array('hue' => '#' . $this->hue);
}
if ($this->invertLightness) {
$style[] = array('invert_lightness' => !!$this->invertLightness);
}
foreach (array('saturation', 'lightness', 'gamma') as $key) {
if ($this->$key) {
$style[] = array($key => (float)$this->$key);
}
}
echo json_encode($style);
?>;
var map = new google.maps.Map(mapElement, {
zoom: <?php echo json_encode($this->zoomLevel * 1) ?>,
scrollwheel: false,
mapTypeControl: false,
streetViewControl: false,
draggable : <?php echo ($this->dragging != null) ? json_encode($this->dragging) : "0"; ?>,
//scaleControl: false,
//overviewMapControl: false,
//panControl: false,
//rotateControl: false,
//zoomControl: false,
styles: [
{featureType: 'landscape', stylers: style},
{featureType: 'road.highway', stylers: style},
{featureType: 'road.arterial', stylers: style},
{featureType: 'road.local', stylers: style},
{featureType: 'water', stylers: style},
{featureType: 'poi', stylers: style},
{featureType: 'icon', stylers: style}
]
});
var geocoder = new google.maps.Geocoder();
geocoder.geocode(
{address: <?php echo json_encode($this->mapAddress) ?>},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
<?php
if($this->icon):?>
icon: '<?php echo $this->icon; ?>',
<?php endif; ?>
position: results[0].geometry.location
});
}
}
);
};
var scripts = document.getElementsByTagName('script');
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = '//maps.googleapis.com/maps/api/js?key=123456789abcdefghijklmnopqrstuvwxyz<?php echo $this->id ?>';
scripts[0].parentNode.insertBefore(script, scripts[0]);
})();
</script>
</div>
Wo liegt der Fehler?
Gruß
Tefracky
Lesezeichen