Merge /u/userid-658405/flightgear/ branch main_next into next
https://sourceforge.net/p/flightgear/fgdata/merge-requests/111/
This commit is contained in:
commit
b7f55350b5
3 changed files with 81 additions and 27 deletions
|
@ -33,19 +33,53 @@
|
|||
title : feature.properties.callsign,
|
||||
alt : feature.properties.callsign,
|
||||
riseOnHover : true,
|
||||
draggable : true,
|
||||
};
|
||||
|
||||
var aiMarker = null;
|
||||
if (feature.properties.type == "aircraft" || feature.properties.type == "multiplayer") {
|
||||
var l1 = feature.properties.callsign,
|
||||
l2 = feature.properties.heading + 'T ' + feature.properties.speed + 'KTAS ' +
|
||||
formatFL(feature.geometry.coordinates[2]);
|
||||
var m = L.aircraftMarker(latlng, { className: AITypeToCssClassMap[feature.properties.type] } );
|
||||
m.on('add', function(e) {
|
||||
|
||||
aiMarker = L.aiAircraftMarker(latlng, { className: AITypeToCssClassMap[feature.properties.type] } );
|
||||
aiMarker.on('add', function(e) {
|
||||
ko.applyBindings( new ViewModel(feature.properties.heading,l1,l2), e.target._icon);
|
||||
});
|
||||
return m;
|
||||
aiMarker.options.draggable = true;
|
||||
//We can't drag multiplayer
|
||||
if(feature.properties.type == "aircraft") {
|
||||
aiMarker.on('dragstart', function(evt) {
|
||||
evt.target.isDragging = true;
|
||||
});
|
||||
|
||||
aiMarker.on('dragend', function(evt) {
|
||||
if( evt.target !== this)
|
||||
return;
|
||||
var pos = evt.target.getLatLng();
|
||||
|
||||
var props = {
|
||||
name : "position",
|
||||
children : [
|
||||
{
|
||||
name : "latitude-deg",
|
||||
value : pos.lat,
|
||||
}, {
|
||||
name : "longitude-deg",
|
||||
value : pos.lng,
|
||||
},
|
||||
],
|
||||
};
|
||||
$.post("json" + feature.properties.path, JSON.stringify(props));
|
||||
evt.target.isDragging = false;
|
||||
});
|
||||
}
|
||||
return aiMarker;
|
||||
}
|
||||
else if(feature.properties.type == "carrier"){
|
||||
aiMarker = new leaflet.Marker(latlng, options);
|
||||
return aiMarker;
|
||||
}
|
||||
return new leaflet.Marker(latlng, options);
|
||||
},
|
||||
|
||||
// onEachFeature : function(feature, layer) {
|
||||
|
@ -66,6 +100,7 @@
|
|||
this.updateId++;
|
||||
},
|
||||
|
||||
// Refresh method called every 10s to reload other aircraft
|
||||
updateId : 0,
|
||||
update : function(id) {
|
||||
var self = this;
|
||||
|
@ -92,6 +127,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
// Builds the GeoJSON representation of AI, Multiplayer and Carriers
|
||||
aiPropsToGeoJson : function(props, types, bounds ) {
|
||||
var geoJSON = {
|
||||
type : "FeatureCollection",
|
||||
|
@ -105,6 +141,7 @@
|
|||
if (!child.getNode("valid").getValue())
|
||||
return;
|
||||
|
||||
var path = child.getPath();
|
||||
var position = child.getNode("position");
|
||||
var orientation = child.getNode("orientation");
|
||||
var velocities = child.getNode("velocities");
|
||||
|
@ -141,6 +178,7 @@
|
|||
},
|
||||
"id" : id,
|
||||
"properties" : {
|
||||
"path" : path,
|
||||
"type" : type,
|
||||
"heading" : heading.toFixed(0),
|
||||
"speed" : speed.toFixed(0),
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
height: 20px;
|
||||
margin-left: -10px;
|
||||
margin-top: -10px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ai-aircraft-marker-icon path {
|
||||
|
|
|
@ -29,33 +29,45 @@ define(
|
|||
|
||||
this.isDragging = false;
|
||||
|
||||
this.on('dragstart', function(evt) {
|
||||
evt.target.isDragging = true;
|
||||
});
|
||||
|
||||
this.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;
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
// Builds the marker for my aircraft
|
||||
L.aircraftMarker = function(latlng, options) {
|
||||
var m = new L.AircraftMarker(latlng, options);
|
||||
m.on('dragstart', function(evt) {
|
||||
if( evt.target !== this)
|
||||
return;
|
||||
evt.target.isDragging = true;
|
||||
});
|
||||
|
||||
m.on('dragend', function(evt) {
|
||||
if( evt.target !== this)
|
||||
return;
|
||||
|
||||
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;
|
||||
});
|
||||
return m;
|
||||
}
|
||||
|
||||
//Builds a marker for a ai or multiplayer aircraft
|
||||
L.aiAircraftMarker = function(latlng, options) {
|
||||
return new L.AircraftMarker(latlng, options);
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +162,10 @@ define(
|
|||
|
||||
if (params && params.selectedOverlays && params.overlays) {
|
||||
params.selectedOverlays.forEach(function(ovl) {
|
||||
params.overlays[ovl].addTo(self.map);
|
||||
if(params.overlays[ovl] != undefined){
|
||||
params.overlays[ovl].addTo(self.map);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue