Add mouse coordinate display to bottom left
This commit is contained in:
		
							parent
							
								
									134d70dc9f
								
							
						
					
					
						commit
						fcc26a7fa5
					
				@ -606,6 +606,31 @@ L.GotoControl = L.MyControl.extend({
 | 
			
		||||
mymap.addControl(new L.SearchControl());
 | 
			
		||||
mymap.addControl(new L.GotoControl());
 | 
			
		||||
 | 
			
		||||
L.CurrentPosControl = L.Control.extend({
 | 
			
		||||
	options: {
 | 
			
		||||
		position : 'bottomleft',
 | 
			
		||||
		callback: null,
 | 
			
		||||
		kind: "",
 | 
			
		||||
		html: ''
 | 
			
		||||
	},
 | 
			
		||||
	onAdd: function (map) {
 | 
			
		||||
		container = L.DomUtil.create('div', 'leaflet-control-scale leaflet-bar');
 | 
			
		||||
		container.style.visibility = "hidden";
 | 
			
		||||
		div = L.DomUtil.create('div', '', container);
 | 
			
		||||
		div.style.backgroundColor = "white";
 | 
			
		||||
		div.style.paddingLeft = "4px";
 | 
			
		||||
		div.style.paddingRight = "4px";
 | 
			
		||||
		div.style.borderRadius = "2px";
 | 
			
		||||
		div.style.margin = "2px";
 | 
			
		||||
		div.style.opacity = "0.6";
 | 
			
		||||
		div.style.fontWeight = "bold";
 | 
			
		||||
		div.innerHTML = "";
 | 
			
		||||
		div.id = "current_position_label";
 | 
			
		||||
		return container;
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
mymap.addControl(new L.CurrentPosControl());
 | 
			
		||||
 | 
			
		||||
var popup = L.popup();
 | 
			
		||||
 | 
			
		||||
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
 | 
			
		||||
@ -687,6 +712,17 @@ function update_outline_visibility() {
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function update_current_mouse_position(e) {
 | 
			
		||||
	var lbl = document.getElementById('current_position_label');
 | 
			
		||||
	if (e.type == "mouseout") {
 | 
			
		||||
		lbl.parentElement.style.visibility = "hidden";
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	lbl.parentElement.style.visibility = "visible";
 | 
			
		||||
	pos = resolve_latlng(e.latlng);
 | 
			
		||||
	lbl.innerHTML =  pos.lng + "," + pos.lat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mymap.on('zoomend', function () {is_user_drag = 1; update_hash_from_position();});
 | 
			
		||||
mymap.on('zoomend', update_aa_status);
 | 
			
		||||
mymap.on('zoomend', update_street_width);
 | 
			
		||||
@ -695,6 +731,8 @@ mymap.on('moveend', update_hash_from_position);
 | 
			
		||||
mymap.on('dragstart', function () { is_user_drag = 1;});
 | 
			
		||||
mymap.on('keydown', function (e) { if (e.originalEvent.code.match(/Arrow.*/)) is_user_drag = 1;});
 | 
			
		||||
mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); });
 | 
			
		||||
mymap.on('mousemove', update_current_mouse_position);
 | 
			
		||||
mymap.on('mouseout', update_current_mouse_position);
 | 
			
		||||
 | 
			
		||||
function onHashChange(e, hash=null) {
 | 
			
		||||
	if (!hash)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user