Mostly you have to follow the Tutorial here
but I modified the code slightly
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=REPLACE_THIS_WITH_YOUR_KEY&sensor=false">
</script>
<script type="text/javascript">
function setUrl(url) {
top.location.href= url;
}
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(32.841231,-117.122551),
zoom: 10,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
var marker_clickable = new google.maps.Marker({
position: new google.maps.LatLng(32.807618,-117.266817),
map: map,
title:"If you click me, you'll follow the link to google.com"
});
google.maps.event.addListener(marker_clickable, 'click', function() {
setUrl('http://google.com');
})
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas" style="width:250px; height:400px"></div>
</body>
</html>
First note the above code won't work until you replace REPLACE_THIS_WITH_YOUR_KEY with your actual key.
Also see that I added another function, setUrl() that is called by the listener of the marker:marker_clickable I added to the custom map. now you can click that marker and it will redirect you to google.com, but you could change it anything. I'm using this code to make a custom Google map in a sidebar.




