Geographic Information Systems Asked by CoderCoder42 on March 13, 2021
I’m trying to put on the map the route of an ads-b plane, I’ve managed this so far …
Poblema is as follows puts all the points since I started to intercept him until the end what is not correct should remain only the last point that shows his exact real time location.
function addMarker(coordinates, data_no) {
//console.log(coordinates);
//var marker = new ol.Feature(new ol.geom.Point(coordinates).transform('EPSG:4326', 'EPSG:31700'));
var marker = new ol.Feature(new ol.geom.Point(coordinates).transform('EPSG:4326', map.getView().getProjection()));
//console.log(marker);
var zIndex = 1;
var style_aircraft = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 36],
anchorXUnits: "fraction",
anchorYUnits: "pixels",
opacity: 1,
src: "img/airport.png",
zIndex: zIndex
})),
zIndex: zIndex,
text: new ol.style.Text({
font: 'bold 16px "Open Sans", "Arial Unicode MS", "sans-serif"',
placement: 'center',
fill: new ol.style.Fill({
color: 'black'
})
})
})
var data = data_no[0]+"/"+data_no[1]+"/"+data_no[2]+"/"+data_no[3];
style_aircraft.getText().setText(data);
marker.setStyle(style_aircraft);
vectorSource.aircraft.addFeature(marker);
}
If data_no[0]
is the id of the plane you could use
marker.setId(data_no[0]);
var old_marker = vectorSource.aircraft.getFeatureById(data_no[0]);
if (old_marker) {
vectorSource.aircraft.removeFeature(old_marker);
}
vectorSource.aircraft.addFeature(marker);
Correct answer by Mike on March 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP