Newer
Older
nikko / late_map.js
var ltlg= [39.00044692389816,140.04415690898898];
//var ltlg=[38.99252972190278,139.95545625686648]; //福山
//var ltlg=[39.00599969340463,140.0435829162598]; //大台野
//マップの中心にする座標

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 mymap = L.map("mymap", {
    layers: [gsiTile], //最初に指定するタイルレイヤー
    center: ltlg, zoom: 16, scrollWheelZoom: false
    //中心座標とズームレベルとマウスのホイールでのズームをしないよう設定
});

//var time= document.getElementById("time");

var baseLayers = {'OpenStreetMap': osmTile, '国土地理院': gsiTile};
//レイヤーの内容
L.control.layers(baseLayers).addTo(mymap);
//レイヤー変更オプション

var kasyo=[],naiyo=[],iro=[],k_type=[],ten=[];

L.geoJson(kaen_Koeki,{
    style: function(feature) {
    	if (feature.properties._storage_options && feature.properties._storage_options.color){
	    switch (feature.properties._storage_options.color) {
		//alert(feature.properties._storege_opions);
    	    case 'Red': return {color: "red"};
	    case 'brown': return {color: "brown"};
	    case 'Cyan': return {color: "cyan"};
	    case 'lime': return {color: "lime"};
            }    
	}
	if (feature.properties._storage_options && feature.properties._storage_options.weight){
	    var hutosa=feature.properties._storage_options.weight;
    	    return {weight: hutosa};
        }
	if (feature.properties._storage_options && feature.properties._storage_options.dashArray){
	    var hakai=feature.properties._storage_options.dashArray;
	    return {dashArray: hakai};   
        }
    },
    onEachFeature: function(feature, layer){
	var propert= feature.properties, geomet=feature.geometry;
	// 予めfeature.propertisをletで宣言。(varでも可)
	if (propert && geomet) {
	    if (propert.name){
		var name=propert.name
	    } else {
		var name="";
	    }
	    if (propert.description){
		var tose=propert.description;
	    } else {
		var tose="";
	    }
	    if (propert._storage_options){
		if (propert._storage_options.color){
		    var color=propert._storage_options.color;
		    iro.push(color);
		}else {
		    color="";
		    iro.push(color);
		}
		if (propert._storage_options.iconClass){
		    var katati=propert._storage_options.iconClass;
		}else {
		    katati="";
		}
		
	    }
	    

	    
	    var type=geomet.type, m=geomet.coordinates;
	    
	    k_type.push(type);
	    
	    //alert(k_type);
	    
	    if (color=="Red" && type=="LineString" && name==""){
	     	name="流雪溝";
	    }else if (color=="brown" && type=="LineString" && name==""){
	     	name="下水";
	    }else if (color=="cyan" && type=="LineString" && name==""){
	     	name="沢";
	    }else if (color=="lime" && type=="LineString" && name==""){
	     	name="生活用水";
	    }else if (color=="" && type=="LineString" && name==""){
		name="農業用水"
	    }
	    if (propert.syasin){
		//alert(propert);
		var syasin=propert.syasin;
		if (syasin && propert.syasin2){
		    //要修正
		    //alert(propert.syasin2);
		    var coment="<h3>"+name+"</h3> <img src=\""+syasin+"\" width=\"300\" height=\"200\"><br><img src=\""+propert.syasin2+"\" width=\"300\" height=\"200\"><br>"+tose+"";
		}else{
		    //alert(syasin);
		    var coment="<h3>"+name+"</h3> <img src=\""+syasin+"\" width=\"300\" height=\"200\"><br><br>"+tose+"";
		}
	    }else if (propert){
		var coment="<h3>"+name+"</h3>"+tose+"";
	    }
	    var mak=layer.bindPopup(coment);
	    if (color=="Red" && type=="Point" && katati==""){
	    	mak.setIcon(r_Icon);
	    }else if (color=="Yellow" && type=="Point" || color=="Gold" && type=="Point" ){
	    	mak.setIcon(y_Icon);	
	    }else if (color=="lightpink" && type=="Point" || color=="LightPink" && type=="Point"){
	    	mak.setIcon(lp_Icon);
	    }else if (color=="lime" && type=="Point" || color=="Lime" && type=="Point"){
	    	mak.setIcon(lime_Icon);
	    }else if (color=="DarkSlateGray" && type=="Point" || color=="darkslategray" && type=="Point" ){
	    	mak.setIcon(DSG_Icon);
	    }else if (katati=="Drop"){
	    	mak.setIcon(hinanjo);
	    }
	    
	    if (type=="LineString"){
		for(i=0; i<m.length; i++){
		    //alert(m[i]);
		    kasyo.push(m[i]);
		    naiyo.push(tose);
		    ten.push(mak);
		    //alert(naiyo);
		}
		// LineStringでの座標を細かくとる
	    }else {
		kasyo.push(m); //この関数外に変数を持って行くために使用
		naiyo.push(tose);
		ten.push(mak);
	    }
	    
	    //kasyo.push(m); //この関数外に変数を持って行くために使用
	    //naiyo.push(tose);
	    
	}
    }}).addTo(mymap);
//alert(k_type);
//geojsonファイルを読みだし