Animation
Animationは、マーカーのアニメーションの種類を表す定数です。google.maps.Animation.{NAME}
という形で指定できます。
定数
名前 | 説明 | 値 |
---|---|---|
BOUNCE | 止めない限り、ずっとバウンドし続ける。 | 1 |
DROP | 上部から一度だけ落ちてくる。 | 2 |
デモ
定数は、マーカーオプションのanimationの値として利用できます。
var opts = {
map: map ,
position: map.getCenter() ,
animation: google.maps.Animation.BOUNCE ,
} ;
var marker = new google.maps.Marker( opts ) ;
サンプルコード
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas {
width: 600px ;
height: 600px ;
}
</style>
</head>
<body>
<div id="map-canvas"></div>
<script src="//maps.googleapis.com/maps/api/js?key={APIキー}"></script>
<script>
// Map
var mapDiv = document.getElementById( "map-canvas" ) ;
var mapOpts = {
center: new google.maps.LatLng( 35, 139 ) ,
zoom: 11 ,
clickableIcons: true ,
disableDefaultUI: false ,
disableDoubleClickZoom: false ,
draggable: true ,
fullscreenControl: false ,
mapTypeId: google.maps.MapTypeId.ROADMAP ,
scrollwheel: false ,
} ;
var map = new google.maps.Map( mapDiv, mapOpts ) ;
// Marker
var markerOpts = {
map: map ,
position: map.getCenter() ,
animation: google.maps.Animation.BOUNCE ,
} ;
var marker = new google.maps.Marker( markerOpts ) ;
</script>
</body>
</html>
参考
- Google Maps JavaScript API: Animation
- Googleの公式リファレンス。