駅または駅間をクリックするとメッセージが表示されます。 クリックした地点の近くに駅と駅間が両方ある場合は駅が優先されます。
var rosen;
function init() {
rosen = new Rosen("map", {
apiKey: "2jr5nchcswemrfjj67jvjaqu", // アクセスキーはサンプル用です。実際にご利用されるときは書き換えてください。
});
rosen.on('selectStationOrSection', function(data) {
var msg = "";
if (data.stations) {
data.stations.forEach(function(station) {
msg += station.name + "\n";
console.log(station);
rosen.setStationMarker(station.code);
});
}
if (data.sections) {
data.sections.forEach(function(section) {
msg += "駅間コード=" + section.code + "\n";
console.log(section);
rosen.highlightSections([section.code]);
});
}
$('#map_message').text(msg);
});
}
window.addEventListener('load', init);