// Map-Initialisation

	function getCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i = 0; i < ca.length; i++) {
			var c = ca[i];
			while (c.charAt(0) == ' ') c = c.substring(1, c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
		}
		return null;
	}

	function setCookie(c_name,c_value,c_expiredays) {
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+c_expiredays);
		document.cookie=c_name+ "=" +escape(c_value)+
		((c_expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

	setCookie('gs_cookie','firstme',1600000);


// Get Data from Cookie

	startlat  = ( getCookie("startlat" ) ? getCookie("startlat" ) : startlat );
	startlon  = ( getCookie("startlon" ) ? getCookie("startlon" ) : startlon );
	startzoom = ( getCookie("startzoom") ? getCookie("startzoom") : startzoom );
	legendcollapsed = ( getCookie("legendcollapsed") ? getCookie("legendcollapsed") : legendcollapsed );
	showScale = ( getCookie("showScale") ? getCookie("showScale") : "block" );


	

	var highlightLayer;
	function highlightFeature(e) {
		highlightLayer = e.target;

		if (e.target.feature.geometry.type === 'LineString') {
		  highlightLayer.setStyle({
			color: '#ffff00',
		  });
		} else {
		  highlightLayer.setStyle({
			fillColor: '#ffff00',
			fillOpacity: 1
		  });
		}
	}
	
	

	
	
	
	var map = L.map('map', {zoomControl:true, maxZoom:maxzoom, minZoom:minzoom}).fitBounds([[0,41],[21,55]]);
	map.flyTo([startlat, startlon], startzoom);
	var hash = new L.Hash(map);
	map.attributionControl.setPrefix('<a href="https://github.com/tomchadwin/qgis2web" target="_blank">qgis2web</a> &middot; <a href="https://leafletjs.com" target="_blank">Leaflet</a> &middot; <a href="https://www.linkedin.com/in/roypopiolek/" target="_blank">LiveMap</a>');
	var autolinker = new Autolinker({truncate: {length: 30, location: 'smart'}});
	
	L.control.zoom2start({
		strings: {title: "Zoom to Start"}
	}).addTo(map);	

	
	L.control.locate({
		strings: {title: "Locate me"}
	}).addTo(map);	
	




	
	
	
	
	
	var measureControl = new L.Control.Measure({
		position: 'topleft',
		activeColor: '#ff0000', 
		primaryLengthUnit: 'meters',
		primaryAreaUnit: 'sqmeters'
	});
	measureControl.addTo(map);
	document.getElementsByClassName('leaflet-control-measure-toggle')[0]
	.innerHTML = '';
	document.getElementsByClassName('leaflet-control-measure-toggle')[0]
	.className += ' fas fa-ruler';

	var bounds_group = new L.featureGroup([]);
	var baseMaps = {};