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

MarkerPlace

MarkerPlaceは、マーカーに紐付ける場所の情報を調整するためのオブジェクトです。

プロパティ

プロパティ名説明
location

LatLng|LatLngLiteral

場所の位置座標。

placeId

string

場所に紐付けるGoogle MapsのPlace ID。

query

string

場所の名前などの検索クエリ。検索した時に引っかかるキーワード。

デモ

マーカーに場所の情報を紐付けます。クエリ文字列によって、情報ウィンドウのリンク先が変わるのを確認しましょう。

var options = {
	location: new google.maps.LatLng( 43.0611, 141.3564 ) ,
	placeId: "" ,
	query: "さっぽろテレビ塔" ,
} ;

var marker = new google.maps.Marker( {
	map: map ,
	position: new google.maps.LatLng( 43.0611, 141.3564 ) ,
	place: options ,
} ) ;

サンプルコード

<!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>
var mapDiv = document.getElementById( "map-canvas" ) ;

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

// Marker
var options = {
	location: new google.maps.LatLng( 43.0611, 141.3564 ) ,
	placeId: "" ,
	query: "さっぽろテレビ塔" ,
} ;

var marker = new google.maps.Marker( {
	map: map ,
	position: map.getCenter() ,
	place: options ,
} ) ;

// InfoWindow
var infoWindow = new google.maps.InfoWindow( {
	content: "さっぽろテレビ塔" ,
} ) ;

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

デモページを開く

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