GitHub
GitHubの内容と同じです
やりたいこと
Leaflet.jsとGoogle.jsを使用してgooglemapを生成してから
指定の位置にマーカーを立ててクリック時に吹き出しを展開させる
参考にしたサイト
Google Maps APIを使って複数のマーカーと吹き出しを設置してみる
Google Maps API ウェブ向け Maps JavaScript API
James Croft’s Block 2197701
index.html
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
</head>
<body>
<div style="width:500px; height:500px" id="map"></div>
<script type='text/javascript'>
var map = new L.Map('map', {center: new L.LatLng(51.51, -0.11), zoom: 9});
var googleLayer = new L.Google('ROADMAP');
map.addLayer(googleLayer);
var myLatlng = new google.maps.LatLng(51.51, -0.11);
var mapOptions = {
zoom: 4,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
title:"Hello World!"
});
infoWindow = new google.maps.InfoWindow({ // 吹き出しの追加
content: '<div class="sample">ロンドンだよ</div>' // 吹き出しに表示する内容
});
marker.addListener('click', function() { // マーカーをクリックしたとき
infoWindow.open(map, marker); // 吹き出しの表示
});
// To add the marker to the map, call setMap();
marker.setMap(map);
</script>
</body>
</html>
