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

[廃止] Marker: attribution

attributionはMarkerクラスのオプションです。マーカーに紐付けた場所に、ウェブサイトの名前やURLなど、補足情報を追加できます。

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

Attribution

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

var opts = {
	map: map ,
	position: map.getCenter() ,
	place: {
		location: new google.maps.LatLng( 35, 139 ) ,
		query: "SYNCERビル (東京スカイツリー内)" ,
	} ,
	attribution: {
		source: "SYNCER" ,
		webUrl: "https://syncer.jp/" ,
	} ,
} ;

デモ

この機能は廃止されたため、動作しません。

カスタム

保存すると、「SYNCERから保存しました」という案内が表示されます。

var marker = new google.maps.Marker( {
	map: map ,
	position: map.getCenter() ,
	place: {
		location: map.getCenter() ,
		query: "SYNCERビル (東京スカイツリー内)" ,
	} ,
	attribution: {
		source: "SYNCER" ,
		webUrl: "https://syncer.jp/" ,
	} ,
} ) ;

デフォルト

保存すると、「保存しました」という案内だけ表示されます。

var marker = new google.maps.Marker( {
	map: map ,
	position: map.getCenter() ,
	place: {
		location: map.getCenter() ,
		query: "SYNCERビル (東京スカイツリー内)" ,
	} ,
} ) ;

サンプルコード

<!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キー}&signed_in=true"></script>
	<script>
var mapDiv = document.getElementById( "map-canvas" ) ;

// Map
var map = new google.maps.Map( mapDiv, {
	center: new google.maps.LatLng( 35, 139 ) ,
	zoom: 11 ,
} ) ;

// Marker
var marker = new google.maps.Marker( {
	map: map ,
	position: map.getCenter() ,
	place: {
		location: map.getCenter() ,
		query: "SYNCERビル (東京スカイツリー内)" ,
	} ,
	attribution: {
		source: "SYNCER" ,
		webUrl: "https://syncer.jp/" ,
	} ,
} ) ;

// InfoWindow
var infoWindow = new google.maps.InfoWindow( {
	content: "SYNCERビル (東京スカイツリー内)" ,
} ) ;

infoWindow.open( map, marker ) ;
	</script>
</body>
</html>

デモページを開く

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