基本的に、マップの中心を新しい緯度と経度に設定する必要があります。このようなもの:
map.setCenter(new google.maps.LatLng(this.latitude, this.longitude));
情報ウィンドウを開くには
myInfoWindow.open(map, yourMarker);
JavaScript を使用すると、イベントを<a>
の onClick に追加し、マップを新しい中心に設定できます。
UPDATE w/ 例: http://jsfiddle.net/kjy112/FEexA/
HTML: Google マップ用の div を作成し、center/info win ポップアップへのリンクも作成します。
<div id='map_canvas'></div>
<a id='marker' href='javascript:showMarker();'>Click Me!</a>
CSS: Google マップ エリアの寸法を設定する
#map_canvas{
width: 400px;
height: 400px;
}
Javascript アクション: ランダムな緯度経度で地図を設定する
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 10,
center: new google.maps.LatLng(35.137879, -82.836914),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
情報ウィンドウでマーカーを作成します。
var myMarker = new google.maps.Marker({
position: new google.maps.LatLng(47.651968, 9.478485),
});
myMarker['infoWin'] = new google.maps.InfoWindow({
content: "<div id='infoWindow'>Your Info Window!</div>"
});
「Click Me!」を処理するコードを次に示します。アンカーがクリックされます:
function showMarker() {
map.setCenter(myMarker.position); //makes myMarker center of map
myMarker.setMap(map); //add the marker to the map
myMarker['infoWin'].open(map, myMarker); //opens the info window associate with the marker
}