browser based map: experimental reposition by drag
new feature for the browser based map: dragging the aircraft symbol teleports the aircraft to the new position after dropping. Beware: - Scenery might not yet be loaded. - New position might be below ground.
This commit is contained in:
parent
0c6203c1c1
commit
fd99fb29d0
1 changed files with 29 additions and 1 deletions
|
@ -271,6 +271,7 @@ html,body,#map {
|
||||||
|
|
||||||
});
|
});
|
||||||
navdbLayer.dirty = true;
|
navdbLayer.dirty = true;
|
||||||
|
|
||||||
navdbLayer.update = function() {
|
navdbLayer.update = function() {
|
||||||
if (navdbLayer.dirty) {
|
if (navdbLayer.dirty) {
|
||||||
navdbLayer.dirty = false;
|
navdbLayer.dirty = false;
|
||||||
|
@ -560,6 +561,7 @@ html,body,#map {
|
||||||
|
|
||||||
var aircraftMarker = new L.RotatedMarker(map.getCenter(), {
|
var aircraftMarker = new L.RotatedMarker(map.getCenter(), {
|
||||||
angle : 45,
|
angle : 45,
|
||||||
|
draggable: true,
|
||||||
icon : L.icon({
|
icon : L.icon({
|
||||||
iconSize : [ 60, 60 ],
|
iconSize : [ 60, 60 ],
|
||||||
iconAnchor : [ 30, 30 ],
|
iconAnchor : [ 30, 30 ],
|
||||||
|
@ -569,7 +571,9 @@ html,body,#map {
|
||||||
zIndexOffset : 10000,
|
zIndexOffset : 10000,
|
||||||
});
|
});
|
||||||
aircraftMarker.addTo(map);
|
aircraftMarker.addTo(map);
|
||||||
|
aircraftMarker.isDragging = false;
|
||||||
aircraftMarker.setState = function(s) {
|
aircraftMarker.setState = function(s) {
|
||||||
|
if( this.isDragging ) return;
|
||||||
var latlng = new L.LatLng(s.lat, s.lon);
|
var latlng = new L.LatLng(s.lat, s.lon);
|
||||||
aircraftMarker.options.angle = s.heading;
|
aircraftMarker.options.angle = s.heading;
|
||||||
aircraftMarker.setLatLng(latlng);
|
aircraftMarker.setLatLng(latlng);
|
||||||
|
@ -577,6 +581,27 @@ html,body,#map {
|
||||||
aircraftMarker.bindPopup(label);
|
aircraftMarker.bindPopup(label);
|
||||||
info.update(s);
|
info.update(s);
|
||||||
};
|
};
|
||||||
|
aircraftMarker.on('dragstart',function(evt){
|
||||||
|
evt.target.isDragging = true;
|
||||||
|
});
|
||||||
|
aircraftMarker.on('dragend',function(evt){
|
||||||
|
var pos = evt.target.getLatLng();
|
||||||
|
var props = {
|
||||||
|
name: "position",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: "latitude-deg",
|
||||||
|
value: pos.lat,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "longitude-deg",
|
||||||
|
value: pos.lng,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
$.post( "/json/", JSON.stringify(props));
|
||||||
|
evt.target.isDragging = false;
|
||||||
|
});
|
||||||
|
|
||||||
var info = L.control();
|
var info = L.control();
|
||||||
info.onAdd = function(map) {
|
info.onAdd = function(map) {
|
||||||
|
@ -598,6 +623,7 @@ html,body,#map {
|
||||||
this._div.innerHTML = s;
|
this._div.innerHTML = s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
var altitudePlotter = L.control({
|
var altitudePlotter = L.control({
|
||||||
position : 'bottomright'
|
position : 'bottomright'
|
||||||
});
|
});
|
||||||
|
@ -658,7 +684,7 @@ html,body,#map {
|
||||||
|
|
||||||
altitudePlotter.addTo(map);
|
altitudePlotter.addTo(map);
|
||||||
altitudePlotter.initPlotter(map);
|
altitudePlotter.initPlotter(map);
|
||||||
|
*/
|
||||||
var FollowAircraftControl = L.control();
|
var FollowAircraftControl = L.control();
|
||||||
FollowAircraftControl.onAdd = function(map) {
|
FollowAircraftControl.onAdd = function(map) {
|
||||||
this._div = L.DomUtil.create('div', 'followAircraft');
|
this._div = L.DomUtil.create('div', 'followAircraft');
|
||||||
|
@ -722,10 +748,12 @@ html,body,#map {
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
PropertyChangeListener(function() {
|
PropertyChangeListener(function() {
|
||||||
|
/*
|
||||||
SetListener("/position/altitude-ft", function(n) {
|
SetListener("/position/altitude-ft", function(n) {
|
||||||
aircraftState.alt = Math.round(n.value);
|
aircraftState.alt = Math.round(n.value);
|
||||||
altitudePlotter.plot.plotPropertyNode(n);
|
altitudePlotter.plot.plotPropertyNode(n);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
SetListener("/position/latitude-deg", function(n) {
|
SetListener("/position/latitude-deg", function(n) {
|
||||||
aircraftState.lat = n.value;
|
aircraftState.lat = n.value;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue