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

[廃止] Marker.getAttribution()

Marker.getAttribution()はMarkerクラスのメソッドです。マーカーに紐付けた場所に設定してある、補足情報を取得します。

バージョン3.28で、この機能は廃止されました。

構文

getAttribution()

パラメータ

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

返り値

Attribution

補足情報を表すAttributionオブジェクト。

デモ

メソッドを実行すると、あらかじめマーカーに紐付けた場所に設定してある補足情報を取得します。

var marker = new google.maps.Marker( {
	map: map ,
	position: new google.maps.LatLng( 43.0611, 141.3564 ) ,
	attribution: {
//	iosDeepLinkId: "" ,
		source: "SYNCER" ,
		webUrl: "https://syncer.jp/" ,
	} ,
} ) ;

// メソッドを実行
map.getAttribution() ;

サンプルコード

<!DOCTYPE html>
<html>
<head>
	<style>
#map-canvas {
	width: 600px ;
	height: 600px ;
}
	</style>
</head>
<body>
	<div id="map-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 mapDiv = document.getElementById( "map-canvas" ) ;

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

	// Map
	var map = new google.maps.Map( mapDiv, {
		center: new google.maps.LatLng( 43.0686601740126, 141.35075529999995 ) ,
		zoom: 18 ,
	} ) ;

	// Marker
	var marker = new google.maps.Marker( {
		map: map ,
		position: map.getCenter() ,
		attribution: {
//		iosDeepLinkId: "" ,
			"source": "SYNCER" ,
			"webUrl": "https://syncer.jp/" ,
		} ,
	} ) ;

	// Method
	document.getElementById( "method" ).onclick = function () {
		var response = marker.getAttribution() ;
		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日 (火)
コンテンツを公開しました。