1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
<div id="mod_fleximap_default<?php echo $module->id;?>" class="mod_fleximap<?php echo $moduleclass_sfx ?>" style="width:<?php echo $width; ?>;height:<?php echo $height; ?>;">
<div id="map" style="position: absolute;width:<?php echo $width; ?>;height:<?php echo $height; ?>;"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false<?php if ($apikey) echo '?key='.$apikey; ?>"></script>
<script type="text/javascript" src="modules/mod_flexigooglemap/assets/js/markerclusterer_compiled.js"></script>
<script type="text/javascript">
<?php
$tMapTips = array();
//Recuperation de point de ma bdd
foreach ($itemsLoc as $itemLoc ){
$coord = unserialize ($itemLoc->value);
$lat = $coord['lat'];
$lon = $coord['lon'];
if (!empty($lat) || !empty($lon) ) {
if ($useadress){
$addre = '<p>'.$coord['addr_display'].'</p>';
$addre = '<p>'.$coord['addr_display'].'</p>';
$addre = addslashes($addre);
}
$coordo = $lat.",".$lon;
//$title = json_encode($itemLoc->title);
$title = addslashes($itemLoc->title);
if ($uselink){
$link = $itemLoc->link;
$link = '<p class="link"><a href="'.$link.'" target="'.$linkmode.'">'.$title.'</a></p>';
}
// echo "myPoints.push( new google.maps.LatLng(". $coord ."),contentString('toto')); \r\n";
//echo "['<h4>$title</h4><p>$addre</p>',". $coordo ."],\r\n";
$tMapTips[] = "['<h4 class=\"fleximaptitle\">$title</h4>$addre $link',". $coordo ."]\r\n";
}
}
$tabMapTipsJS = implode(",", $tMapTips);
?>
// nouveau script
// Define your locations: HTML content for the info window, latitude, longitude
var locations = [ <?php echo $tabMapTipsJS; ?> ];
var icons = [<?php echo $markerdisplay; ?>]
var iconsLength = icons.length;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-37.92, 151.25),
mapTypeId: google.maps.MapTypeId.<?php echo $maptype;?>,
mapTypeControl: false,
streetViewControl: false,
panControl: false,
zoomControlOptions: {
position: google.maps.ControlPosition.LEFT_BOTTOM
}
});
var infowindow = new google.maps.InfoWindow({
maxWidth: 160
});
var markers = new Array();
var iconCounter = 0;
// Add the markers and infowindows to the map
for (var i = 0; i < locations.length; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
<?php if($animationmarker){
//animation option
echo 'animation: google.maps.Animation.DROP,';
}
?>
icon: icons[iconCounter]
});
markers.push(marker);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
iconCounter++;
// We only have a limited number of possible icon colors, so we may have to restart the counter
if(iconCounter >= iconsLength) {
iconCounter = 0;
}
}
function autoCenter() {
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds();
// Go through each...
for (var i = 0; i < markers.length; i++) {
bounds.extend(markers[i].position);
}
// Fit these bounds to the map
map.fitBounds(bounds);
}
<?php if ($clustermode) {
echo "var mcOptions = {gridSize:$gridsize, maxZoom:$maxzoom};\r\n";
echo "var marker = new MarkerClusterer(map, markers, mcOptions);\r\n";
}
?>
autoCenter();
</script>
</script>
</div> |
Partager