This commit is contained in:
2018-01-29 11:43:21 +01:00
parent 615912e6a0
commit eabe086f95
5 changed files with 67 additions and 99 deletions

View File

@@ -174,21 +174,11 @@
<a name="carte"></a><p>&nbsp;</p>
<!--div id="map_canvas1" ></div>
<div id="map_canvas2" ></div>
<div id="map_canvas3" ></div>
<div id="map_canvas4" ></div>
<div id="map_canvas5" ></div>
<div id="map_canvas6" ></div-->
<?php
echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>';
?>
<script>
// Define your locations: HTML content for the info window, latitude, longitude
<script>
function initMap() {
var locations = [
<?php
$j = (count($coord) - 1);
@@ -198,9 +188,9 @@ echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none")
}
?>
];
// Setup the different icons and shadows
var iconURLPrefix = 'http://maps.google.com/mapfiles/ms/icons/';
var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/';
var icons = [
iconURLPrefix + 'red-dot.png',
@@ -213,89 +203,50 @@ echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none")
]
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.ROADMAP,
mapTypeControl: false,
streetViewControl: false,
panControl: false,
zoomControlOptions: {
position: google.maps.ControlPosition.LEFT_BOTTOM
}
window.map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow({
maxWidth: 200
});
var infowindow = new google.maps.InfoWindow();
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,
icon: icons[iconCounter]
});
var bounds = new google.maps.LatLngBounds();
markers.push(marker);
infoBubble = new InfoBubble({
map: map,
content: '',
/*content: '<div class="mylabel">The label</div>',
position: new google.maps.LatLng(-32.0, 149.0),*/
shadowStyle: 0,
padding: 5,
backgroundColor: 'rgb(230,230,230)',
borderRadius: 5,
arrowSize: 10,
borderWidth: 1,
borderColor: '#2c2c2c',
disableAutoPan: true,
hideCloseButton: true,
arrowPosition: 30,
backgroundClassName: 'transparent',
disableAnimation: true,
arrowStyle: 2
});
var iconCounter = 0;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: icons[iconCounter]
});
/*var contentString = '<div style="width: 94.2%; padding-left:10px; height: 25px;float: left;color: #FFF;background: #ed1e79;line-height: 25px;border-radius:5px 5px 0px 0px;">'
contentString += '<strong><b>"You feild"</b></strong></div>'*/
bounds.extend(marker.position);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
/*infowindow.setContent(locations[i][0]);
infowindow.setContent(contentString);
infowindow.open(map, marker);*/
infoBubble.setContent(locations[i][0]);
infoBubble.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;
}
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
/*
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">' + locations[i][0] + '</h1>'+
'<div id="bodyContent">'+
'</div>'+
'</div>';
infowindow.setContent(contentString);
*/
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
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);
}
autoCenter();
</script>
map.fitBounds(bounds);
var listener = google.maps.event.addListener(map, "idle", function () {
map.setZoom(8);
google.maps.event.removeListener(listener);
});
}
</script>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
@@ -376,4 +327,5 @@ echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none")
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
<?php endwhile; // end of the loop. ?>