SYNCERのロゴ
アイキャッチ画像

StreetViewPanorama.getMotionTracking()

getMotionTracking()はStreetViewPanoramaクラスのメソッドです。ストリートビューで、現在、モーション・トラッキングが有効か否かを確認できます。

構文

getMotionTracking()

パラメータ

パラメータはありません。

返り値

boolean

モーション・トラッキングが有効な場合はtrue、無効な場合はfalseが返る。コントローラを操作するなどして明示的にmotionTrackingを指定していない段階では、undefinedが返る。

デモ

メソッドを実行すると、現在、モーション・トラッキングが有効か否かを取得します。このデモはスマホなどのデバイスでご確認下さい。

var streetViewPanorama = new google.maps.StreetViewPanorama( container, {
	position: new google.maps.LatLng( 35.794361,139.791421 ) ,
	motionTracking: true ,
} ) ;

// メソッドを実行
streetViewPanorama.getMotionTracking() ;

サンプルコード

<!DOCTYPE html>
<html>
<head>
	<style>
#streetview-canvas {
	width: 600px ;
	height: 600px ;
}
	</style>
</head>
<body>
	<div id="streetview-canvas"></div>
	<p><button id="method">メソッドを実行</button><button id="reset">リセット</button></p>
	<p><textarea id="response"></textarea></p>

	<script src="//maps.googleapis.com/maps/api/js?key={APIキー}"></script>
	<script>
function initialize() {
	var container = document.getElementById( "streetview-canvas" ) ;

	var responseTextarea = document.getElementById( "response" ) ;
	responseTextarea.value = "" ;

	// StreetViewPanorama
	var streetViewPanorama = new google.maps.StreetViewPanorama( container, {
		position: new google.maps.LatLng( 35.794361,139.791421 ) ,
		motionTracking: true ,
	} ) ;

	// Method
	document.getElementById( "method" ).onclick = function () {
		var response = streetViewPanorama.getMotionTracking() ;
		try{ response = typeof response == "object" ? JSON.stringify( response ) : response ; }catch(e){}
		responseTextarea.value = response ;
		console.log( response ) ;
	}
}

// Reset
document.getElementById( "reset" ).onclick = initialize ;

initialize() ;
	</script>
</body>
</html>

デモページを開く

  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2015年9月1日 (火)
コンテンツを公開しました。