Zitat von
Andreas
Dann bist du da wahrscheinlich in zwei unterschiedlichen Templates. Das eine weiß nichts von einer Variablen $info.
ps In $info würde also immer nur der Inhalt des letzten $arrItem aus der foreach-Schleife stehen?
Ist alles in einem Template zwar etwas lang aber ich poste es trotzdem mal, vllt können es ja noch andere gebrauchen.
Da geht es eben darum den MM Detail Link in die Infobox zu packen, was mir bisher nicht gelungen ist.
Das Beispiel ist auf meiner Demoseite http://ecoblack.de/locations.html online.
PHP-Code:
<?php if ($this->items->getCount()): ?>
<script>
var arrInfoBoxes = new Array();
function gmap1_dynmap(gmap1) {
<?php
foreach($this->items->parseAll($this->getFormat(), $this->view) as $arrItem):
$name = htmlspecialchars($arrItem['text']['name'], ENT_QUOTES);
$url = $arrItem['text']['url'];
// check if url begins with http://
$parsedURL = parse_url($url);
if (empty($parsedURL['scheme'])) { $url = 'http://' . ltrim($url, '/'); }
$geolocation = $arrItem['text']['geolocation'];
$address = preg_replace( "/\r|\n/", "<br>", $arrItem['text']['adresse']);
$id = $arrItem['raw']['id'];
$info = '<div class="gmap-infobox-tip"></div>';
$info .= '<div class="gmap-infobox-content">';
$info .= '<p class="name">' .$name .'</p>';
$info .= '<p><a target="_blank" href="' .$url .'">' .$url .'</a></p>';
$info .= '<p>' .$address .'</p>';
$info .= '</div>';
?>
//<?php if ($arrItem['jumpTo']['deep']): ?>
//<a href="<?= $arrItem['jumpTo']['url'] ?>"><?= $this->details ?></a>
//<?php endif; ?>
// Create Marker
var gmap1_<?php echo $id; ?>_marker = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $geolocation; ?>),
map: gmap1,
title:"<?php echo $name; ?>",
icon: new google.maps.MarkerImage(
'files/theme/metamodels/nail.png',
new google.maps.Size(11, 21),
new google.maps.Point(0,0),
new google.maps.Point(5,21)
)
});
// zoom & center
gmap1.center = new google.maps.LatLng(<?php echo $geolocation; ?>);
gmap1.zoom = 12;
// create Infobox
var gmap1_<?php echo $id; ?>_infobox1 = new google.maps.InfoWindow({
content: '<?php echo $info; ?>',
disableAutoPan: false,
maxWidth: 150,
boxClass: 'gmap-infobox',
pixelOffset: new google.maps.Size(0, -5),
zIndex: null,
closeBoxMargin: '18px 8px 2px 2px',
closeBoxURL: 'http://www.google.com/intl/en_us/mapfiles/close.gif'
});
arrInfoBoxes[arrInfoBoxes.length] = gmap1_<?php echo $id; ?>_infobox1;
// Create Event Listener
google.maps.event.addListener(gmap1_<?php echo $id; ?>_marker, 'click', function() {
// close all info boxes
var i;
for (i = 0; i < arrInfoBoxes.length; i++) {
arrInfoBoxes[i].close();
}
gmap1_<?php echo $id; ?>_infobox1.open(gmap1, this);
})
<?php endforeach; ?>
}
</script>
<?php endif; ?>
Lesezeichen