63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
<script type="text/javascript">
|
|
|
|
//var latlng = new google.maps.LatLng(47.087170, 6.713577);
|
|
/**/
|
|
var contentString = "<?php echo $title_marker; ?>";
|
|
var curr_infw;
|
|
var latlng = new google.maps.LatLng(<?php echo $gm_lat; ?>, <?php echo $gm_lng; ?>);
|
|
var myOptions = {
|
|
/* http://code.google.com/intl/fr/apis/maps/documentation/javascript/reference.html#MapOptions */
|
|
zoom: 11,
|
|
center: latlng,
|
|
scrollwheel: true,
|
|
scaleControl: false,
|
|
disableDefaultUI: false,
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
/*
|
|
navigationControl: true,
|
|
navigationControlOptions: {
|
|
style: google.maps.NavigationControlStyle.SMALL
|
|
}*/
|
|
};
|
|
var map = new google.maps.Map(document.getElementById("map"), myOptions);
|
|
|
|
marker = createMarker(latlng, '', contentString, map);
|
|
|
|
function createMarker(point, title, content, map) {
|
|
var myMarkerImage = new google.maps.MarkerImage('http://maps.google.com/mapfiles/arrow.png');
|
|
var myMarkerShadow = new google.maps.MarkerImage('http://maps.google.com/mapfiles/arrowshadow.png');
|
|
var marker = new google.maps.Marker({
|
|
position: point,
|
|
map: map,
|
|
icon: myMarkerImage,
|
|
shadow: myMarkerShadow,
|
|
title: title
|
|
});
|
|
var infowindow = new google.maps.InfoWindow({
|
|
//content: content
|
|
content: createInfo(content,content),
|
|
//width: 500,
|
|
//height: 400
|
|
});
|
|
|
|
google.maps.event.addListener(marker, 'click', function() { /* mouseover */
|
|
if(curr_infw) { curr_infw.close();} // We check to see if there is an info window stored in curr_infw, if there is, we use .close() to hide the window
|
|
curr_infw = infowindow; // Now we put our new info window in to the curr_infw variable
|
|
infowindow.open(map, marker); // Now we open the window
|
|
});
|
|
return marker;
|
|
};
|
|
|
|
// Create information window
|
|
function createInfo(title, content) {
|
|
var html = '<div class="infowindow">';
|
|
html += '<strong>'+ title +'</strong>';
|
|
html += '<p>'+content+'</p>';
|
|
html += '<ul><li>Lat: <?php echo $gm_lat; ?></li>';
|
|
html += '<li>Long: <?php echo $gm_lng; ?></li>';
|
|
html += '</div>';
|
|
return html;
|
|
}
|
|
|
|
</script>
|