我在使用下面的代碼給Google地圖標記添加URL時遇到了一些麻煩。Google地圖標記網址?
假設我只是想添加一個HREF(到Google.com或其他)到「wpl_map_marker_image」,所以通過點擊標記圖像它會去那裏,我會如何添加下面的代碼?
<script type="text/javascript">
function wplookInitMap() {
// Define the centre of the map and the position of the marker
var mapCenter = {
lat: <?php echo $wpl_map_latitude; ?>,
lng: <?php echo $wpl_map_longitude; ?>
};
// Define map options
var mapOptions = {
zoom: <?php echo $wpl_map_zoom; ?>,
center: mapCenter,
draggable: false,
disableDefaultUI: true,
scrollwheel: false,
<?php echo (!empty($wpl_map_snazzy_style) ? 'styles: ' . $wpl_map_snazzy_style : ''); ?>
};
// Generate the map
var map = new google.maps.Map(document.getElementById('contactMap'), mapOptions);
// Add a marker
var beachMarker = new google.maps.Marker({
position: mapCenter,
map: map,
<?php echo (!empty($wpl_map_marker_image) ? 'icon: \'' . $wpl_map_marker_image . '\'' : ''); ?>
});
// Center the map when the user resizes the window
google.maps.event.addDomListener(window, 'resize', function() {
map.setCenter(mapCenter);
});
}
// Generate the map on page load
if (!window.addEventListener) {
window.attachEvent('load', wplookInitMap);
} else {
window.addEventListener('load', wplookInitMap, false);
}
</script>