Compare commits
	
		
			4 Commits
		
	
	
		
			de3a4fc757
			...
			c10f229f49
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c10f229f49 | |||
| 6284c9d8b4 | |||
| 828e1edf28 | |||
| 3d0e8ae95d | 
@ -83,6 +83,29 @@ function load_svg(name, url, active=1) {
 | 
			
		||||
	xhttp_ps.send();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function json_center_on_block(json) {
 | 
			
		||||
	for (var i = 0; i < json.length; i++) {
 | 
			
		||||
		if (json[i].geometry && json[i].geometry.coordinates) {
 | 
			
		||||
			switch (json[i].geometry.type) {
 | 
			
		||||
			case "Point":
 | 
			
		||||
					json[i].geometry.coordinates[0] += 0.5;
 | 
			
		||||
					json[i].geometry.coordinates[1] += 0.5;
 | 
			
		||||
				break;
 | 
			
		||||
			case "LineString":
 | 
			
		||||
				for (var j = 0; j < json[i].geometry.coordinates.length; j++) {
 | 
			
		||||
					json[i].geometry.coordinates[j][0] += 0.5;
 | 
			
		||||
					json[i].geometry.coordinates[j][1] += 0.5;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				console.log("centering: Type " + json[i].geometry.type + " not yet implemented.");
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return json;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function load_tiles(name, id) {
 | 
			
		||||
	var satellite = L.tileLayer('https://notsyncing.net/maps.linux-forks.de/tiles/?id={id}&z={z}&x={x}&y={y}', {
 | 
			
		||||
		maxZoom: 14 /*8*/,
 | 
			
		||||
@ -136,7 +159,8 @@ function load_geojson(name, url, iconname, iconcolor, active=1, style={}) {
 | 
			
		||||
						};
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
				var geojson = L.geoJSON(JSON.parse(xhttp_ps.responseText), {
 | 
			
		||||
				var json = json_center_on_block(JSON.parse(xhttp_ps.responseText));
 | 
			
		||||
				var geojson = L.geoJSON(json, {
 | 
			
		||||
					style: style,
 | 
			
		||||
					onEachFeature: onEachFeature,
 | 
			
		||||
					pointToLayer: pointToLayer
 | 
			
		||||
@ -146,7 +170,7 @@ function load_geojson(name, url, iconname, iconcolor, active=1, style={}) {
 | 
			
		||||
					geojson.addTo(mymap);
 | 
			
		||||
				return geojson;
 | 
			
		||||
			} else {
 | 
			
		||||
				alert("Error: Could not load geojson map layer (" + name + ").");
 | 
			
		||||
				console.log("Error: Could not load geojson map layer (" + name + ").");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -168,6 +192,7 @@ load_geojson("CW Complexes", "./geojson/cw_complexes.json", "border-all", "black
 | 
			
		||||
load_geojson("Courts", "./geojson/courts.json", "balance-scale", "black");
 | 
			
		||||
load_geojson("Waterway", "./geojson/waterway.json", "water", "darkblue");
 | 
			
		||||
load_geojson("Train Depots", "./geojson/depots.json", "wrench", "violet");
 | 
			
		||||
load_geojson("Streets", "./geojson/streets.json", "street", "blue", 0);
 | 
			
		||||
 | 
			
		||||
L.control.scale().addTo(mymap);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,6 @@ if (urlParams.has('editor')) {
 | 
			
		||||
 | 
			
		||||
	function strToPoints(str) {
 | 
			
		||||
		var temp = JSON.parse("[" + str + "]"); // TODO: add .5 everwhere
 | 
			
		||||
		console.log(temp);
 | 
			
		||||
		return temp;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user