/****************************************************
 * leaflet Init 	
 ***************************************************/	

var map = L.map('map').setView([38.0, 138.9773654], 6);
var layer = L.tileLayer(
	'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
	{
//		attribution: 'Map data &copy; ' + '<a href="http://openstreetmap.org">OpenStreetMap</a>',
		attribution: 'Map data &copy; ' + 'OpenStreetMap',
		maxZoom: 18
	}
).addTo(map);

var geojsonLayer = L.geoJson(null, {onEachFeature:drawItem}).addTo(map);





/****************************************************
 * mapping
 ***************************************************/	

function drawItem(feature, layer) {
	if (!feature.properties) return ;
	var p = feature.properties;
	var properties = '<div class="popup">';
	if (p.name) properties += '<center>'+ p.name + '<center>';
	if (p.name) properties += '<hr />';

	if (feature.runners){
		feature.runners.forEach(function(r){
            if (r.runner_name) properties += '<center>'+ r.kukan +  '区 '+ r.runner_name + '<center>';
            if (r.img_url) properties += '<center><a href="'+ r.link + '" target="_new"><img src="'+ r.img_url + '" /></a></center>';
		});
	}

	properties += '</div>';
	layer.bindPopup(properties);
}