Newer
Older
latlng_remake / domon.js
@natto natto on 17 Aug 2018 5 KB aaa
/* domon.js - 北緯38.891度, 東経139.824度, ズームレベル16 で地図表示 */

var mymap = L.map("mymap").setView([38.891, 139.824], 16);
L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
 attribution:
   '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);

var arc = [			// Polyline: 連続線分
    [38.898579,139.8179],
    [38.898660,139.8179],
    [38.898182,139.817151],
    [38.8976,139.81689],
    [38.9007,139.82203],
    [38.901579,139.823192],
    [38.908870,139.835738],
    [38.911714,139.834907],
    [38.912711,139.835],
    [38.916805,139.837161],
    [38.916008,139.839764],
    [38.915771,139.83962]
];

var polyline = L.polyline([arc]).addTo(mymap);
var decorator = L.polylineDecorator(polyline, {
    patterns: [
        // defines a pattern of 10px-wide dashes, repeated every 20px on the line
	{offset: 0, repeat: 40, symbol: L.Symbol.arrowHead({pixelSize: 30})}
    ]
}).addTo(mymap);
var ver=L.version;

var count=0;
//alert(L.version);
var kasyo=[],naiyo=[],iro=[],k_type=[],ten=[],coments=[],usepan=[],mkname=[];
var customLayer=L.geoJson(null,{
    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 unji(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 (propert){
		if(type=="Point"){
		    var Point_id=type+count;
		    //var SMC=setMovieandComents(tose);
		    //alert(SMC[1]);
		    unko=0;
		    if(unko==undefined){
			var coment="<div id="+Point_id+"><h3>"+name+"</h3><h1>"+SMC[0]+"</h1></div>";
			count++;
			coments.push(coment);
			usepan.push(m);
			mkname.push(name);
		    }else{
			point_id=11;	
			var coment="<div id="+Point_id+"><h1>"+name+"</h1><h3>"+unko+"</h3></div>";
			//var movie=SMC[1];
			var movie="<div id="+point_id+"><a href=\"https://www.yatex.org/gitbucket/SKIP/traditional/raw/master/2018/kadota/KadotaKagura-640.webm\"></a></div>"
			count++;
			coments.push(movie);
			usepan.push(m);
			mkname.push(name);
		    }
		    //alert(coment);
		    //console.log(coments);
		}else{
		    var coment="<h1>"+name+"</h1><h3>"+tose+"</h3>";
		}
	    }
	    //console.log(layer);
	    var mak=layer.bindPopup(coment);
	    //console.log(mak);
	    
	    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);
	    
	}
    })
});


var gjl = omnivore.geojson('restrant.geojson', null, customLayer).on('ready', function() {
    mymap.fitBounds(gjl.getBounds());
    console.log(usepan[1]);
    var unshi=L.latLng(usepan[0]);
    console.log(unshi.wrap());
}).addTo(mymap);

var a=document.getElementById("unko");

unko.innerHTML=""+ver+"";