var osmTile =
    L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
	attribution:
	'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> \
contributors'
    });

var gsiTile = 
    L.tileLayer('//cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', {
	attribution:
	'<a href="http://maps.gsi.go.jp/development/ichiran.html">国土地理院</a>'
    });

var ltlg=[38.891, 139.824];

var map_OSM= L.map("map_OSM",{
    layers: [osmTile], //最初に指定するタイルレイヤー
    center: ltlg, zoom: 14, scrollWheelZoom: false,subdomains: 'abcd'
});

var map_GSI= L.map("map_GSI",{
    layers: [gsiTile], //最初に指定するタイルレイヤー
    center: ltlg, zoom: 14, scrollWheelZoom: false
});

map_OSM.sync(map_GSI, {syncCursor: true});
map_GSI.sync(map_OSM, {syncCursor: true});

map_OSM.on("click", function(e){ //map click Event
    var popup = L.popup()
    .setLatLng(e.latlng) //
    .setContent('<h1>ここの位置情報だよ</h1><p>'+e.latlng+'</p>')
    .openOn(map_GSI);
});

function on_click(Base_map1,Base_map2){

    Base_map1.on("click", function(e){ //map click Event
	var popup1 = L.popup()
	    .setLatLng(e.latlng) // popup_action in function
	    .setContent('<h1>ここの位置情報だよ1の巻</h1><p>'+e.latlng+'</p>');
	var popup2 = L.popup()
	    .setLatLng(e.latlng) //
	    .setContent('<h1>ここの位置情報だよ2の巻</h1><p>'+e.latlng+'</p>');
	popup1.openOn(Base_map1);
	popup2.openOn(Base_map2);
    });
    
};

on_click(map_GSI,map_OSM);
on_click(map_OSM,map_GSI);

L.marker([38.8916436801475,139.81986558030144]).bindPopup("pokemon").addTo(map_GSI);

L.marker([38.8916436801475,139.81986558030144]).bindPopup("pokemon").addTo(map_OSM);

var fx = new L.PosAnimation();
fx.run(map_OSM, [300, 500], 0.5);
