Maps API v3 SVG markers
HTML
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map-canvas"></div>
CSS
#map-canvas
{
height: 400px;
width: 500px;
}
JavaScript
var map;
var marker;
var bounceTimer;
function initialize() {
var mapOptions = {
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(0,0)
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
marker = new google.maps.Marker({
draggable: false,
position: new google.maps.LatLng(0,0),
map: map,
optimized:false
});
google.maps.event.addListener(marker, 'mouseover', function() {
if (this.getAnimation() == null || typeof this.getAnimation() === 'undefined') {
/*
Because of the google maps bug of moving cursor several times over and out of marker
causes bounce animation to break - we use small timer before triggering the bounce animation
*/
clearTimeout(bounceTimer);
var that = this;
bounceTimer = setTimeout(function(){
that.setAnimation(google.maps.Animation.BOUNCE);
},
500);
}
});
google.maps.event.addListener(marker, 'mouseout', function() {
if (this.getAnimation() != null) {
this.setAnimation(null);
}
// If we already left marker, no need to bounce when timer is ready
clearTimeout(bounceTimer);
});
}
initialize();