Jump to content

mattia

Members
  • Posts

    267
  • Joined

  • Last visited

Posts posted by mattia

  1. Hi all,

    How can add a liverefresh for polyline on this code? I already have a liverefresh function, but for the polyline don't work. The marker position is updated but the position of the polyline no

    var flightMarkers = [];
    var routeMarkers = [];
    var flightPath = null;
    var depMarker = null, arrMarker = null;
    var info_window= null;
    var run_once = false;
    var mapOptions = {
    zoom: 4,
    center: new google.maps.LatLng(47.437047,19.248515),
    mapTypeId: google.maps.MapTypeId.ROADMAP };
    var map = new google.maps.Map(document.getElementById("acarsmap"), mapOptions);
    var weatherLayer = new google.maps.weather.WeatherLayer({ temperatureUnits: google.maps.weather.TemperatureUnit.CELSIUS }); weatherLayer.setMap(null);
    var cloudLayer = new google.maps.weather.CloudLayer(); cloudLayer.setMap(null)
    setWindSpeed(google.maps.weather.WindSpeedUnit.KILOMETERS_PER_HOUR)
    var defaultOptions = {
    autozoom: true,
    refreshTime: 5000,
    autorefresh: true
    };
    function toggleClouds() {
    cloudLayer.setMap(cloudLayer.getMap() ? null : map);
    }
    function toggleIcons() {
    weatherLayer.setMap(weatherLayer.getMap() ? null : map);
    }
    function setWindSpeed(units) {
    weatherLayer.setOptions({'windSpeedUnits': units});
    }
    var options = $.extend({}, defaultOptions, acars_map_defaults);
    
    
    
    
    // They clicked the map
    google.maps.event.addListener(map, 'click', function()
    {
    clearPreviousMarkers();
    });
    
    liveRefresh();
    if(options.autorefresh == true)
    {
    setInterval(function () { liveRefresh(); }, options.refreshTime);
    }
    
    function liveRefresh()
    {
    $.ajax({
    type: "GET",
    url: url + "/action.php/acars/data_test",
    dataType: "json",
    cache: false,
    success: function(data)
    {
    populateMap(data);
    }
    });
    };
    
    function populateMap(data)
    {
    clearMap();
    $("#pilotlist").html("");
    
    if (data.length == 0) {
    return false;
    }
    
    var lat, lng;
    
    var details, row, pilotlink;
    var bounds = new google.maps.LatLngBounds();
    
    for (var i = 0; i < data.length; i++)
    {
    if(data[i] == null || data[i].lat == null || data[i].lng == null
    || data[i].lat == "" || data[i].lng == "") {
    continue;
    }
    
    lat = data[i].lat;
    lng = data[i].lng;
    
    
    if(i%2 == 0)
    data[i].trclass = "even";
    else
    data[i].trclass = "odd";
    
    // Pull ze templates!
    var map_row = tmpl("acars_map_row", {flight: data[i]});
    var detailed_bubble = tmpl("acars_map_bubble", {flight: data[i]});
    
    $('#pilotlist').append(map_row);
    
    var pos = new google.maps.LatLng(lat, lng);
    
    var image = new google.maps.MarkerImage(url+"/lib/images/inair/"+data[i].heading+".png",
    new google.maps.Size(41,41),
    new google.maps.Point(0, 0),
    new google.maps.Point(20, 20)
    );
    
    flightMarkers[flightMarkers.length] = new google.maps.Marker({
    position: pos,
    map: map,
    icon: image,
    flightdetails: data[i],
    infowindow_content: detailed_bubble
    });
    
    bounds.extend(pos);
    
    google.maps.event.addListener(flightMarkers[flightMarkers.length - 1], 'click', function()
    {
    
    
    var focus_bounds = new google.maps.LatLngBounds();
    
    // Flight details info window
    info_window = new google.maps.InfoWindow({
    content: this.infowindow_content,
    position: this.position
    });
    
    info_window.open(map, this);
    
    
    var dep_location = new google.maps.LatLng(this.flightdetails.deplat, this.flightdetails.deplng);
    var arr_location = new google.maps.LatLng(this.flightdetails.arrlat, this.flightdetails.arrlng);
    
    
    depMarker = new google.maps.Marker({
    position: dep_location,
    map: map,
    icon: depicon,
    title: this.flightdetails.depname,
    zIndex: 100
    });
    
    
    arrMarker = new google.maps.Marker({
    position: arr_location,
    map: map,
    icon: arricon,
    title: this.flightdetails.arrname,
    zIndex: 100
    });
    
    
    focus_bounds.extend(this.position);
    
    var something = [];
    $.each( this.flightdetails.puntirotta, function( key, val ) {
    something.push(new google.maps.LatLng(val.Latitude, val.Longitude));
    });
    
    //THIS IS THE POLYLINE I WOULD ADD TO LIVE REFRESH
    flightPath = new google.maps.Polyline({
    path: something,
    strokeColor: "#FF0000",
    geodesic : true,
    strokeOpacity: 1.0,
    strokeWeight: 2
    });
    
    map.fitBounds(focus_bounds);
    flightPath.setMap(map);
    
    });
    }
    
    // If they selected autozoom, only do the zoom first time
    if(options.autozoom == true && run_once == false)
    {
    map.fitBounds(bounds);
    run_once = true;
    }
    }
    
    
    function clearPreviousMarkers()
    {
    if(info_window)
    {
    info_window.close();
    info_window = null;
    }
    
    if(depMarker != null)
    {
    depMarker.setMap(null);
    depMarker = null;
    }
    
    if(arrMarker != null)
    {
    arrMarker.setMap(null);
    arrMarker = null;
    }
    
    if(routeMarkers.length > 0)
    {
    for(var i = 0; i < routeMarkers.length; i++) {
    routeMarkers[i].setMap(null);
    }
    }
    
    routeMarkers.length = 0;
    
    if(flightPath != null)
    {
    flightPath.setMap(null);
    flightPath = null;
    }
    }
    
    function clearMap()
    {
    if(flightMarkers.length > 0)
    {
    for(var i = 0; i < flightMarkers.length; i++) {
    flightMarkers[i].setMap(null);
    }
    }
    
    flightMarkers.length = 0;
    
    if(routeMarkers.length > 0)
    {
    for(var i = 0; i < routeMarkers.length; i++) {
    routeMarkers[i].setMap(null);
    }
    }
    
    routeMarkers.length = 0;
    }

  2. Hi Guys,

    i need help with the json for the phpvms live map, this is the exmple code

    [{"flightnum":"IV7050","deptime":"2016-06-01 16:47:00","arrtime":"17:01:39","gs":"397","alt":"26955","lat":"41.340347359635","lng":"-72.46185414378","phasedetail":"Climbing","timeremaining":"07:45:00","online":"No","depicao":"KJFK","arricao":"LFPO","heading":"68","distremain":"3080","aircraftname":"B747-400",

    "zone":"[{"Latitude":34.647995,"Longitude":-86.738549}]",

    "code":"IV","pilotid":"IV0018","firstname":"Mattia","lastname":"test","deplat":"40.6398","deplng":"-73.7789","arrlat":"48.7253","arrlng":"2.35944","route_details":[],"percomplete":2.32,"distremaining":"3080","pilotname":"Mattia"}]

    I have added a field called "zone" but how to remove the double quotes (marked in red) only for this field??

    please help me

    Thanks

    Mattia

  3. Hello,

    i try to add a flight path on live map like flightradar24 but i have a problem with the code,

    this is the json link with new field called "puntirotta" contains the step by step lat and lng saved during flight: http://iv.italianivo...cars/data_test

    I need help to add the content of the field "puntirotta" from json to a variable. SEE THE CODE BELOW

    /**
    * phpVMS - Virtual Airline Administration Software
    * Copyright (c) 2008 Nabeel Shahzad
    * For more information, visit www.phpvms.net
    * Forums: http://www.phpvms.net/forum
    * Documentation: http://www.phpvms.net/docs
    *
    * phpVMS is licenced under the following license:
    * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
    * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
    *
    * @author Nabeel Shahzad
    * @copyright Copyright (c) 2008, Nabeel Shahzad
    * @link http://www.phpvms.net
    * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
    *
    * Rewritten for Google Maps v3
    */
    var flightMarkers = [];
    var routeMarkers = [];
    var flightPath = null;
    var depMarker = null, arrMarker = null;
    var info_window= null;
    var run_once = false;
    var mapOptions = {
    zoom: 4,
    center: new google.maps.LatLng(47.437047,19.248515),
    mapTypeId: google.maps.MapTypeId.HYBRID };
    var map = new google.maps.Map(document.getElementById("acarsmap"), mapOptions);
    var weatherLayer = new google.maps.weather.WeatherLayer({ temperatureUnits: google.maps.weather.TemperatureUnit.CELSIUS }); weatherLayer.setMap(null);
    var cloudLayer = new google.maps.weather.CloudLayer(); cloudLayer.setMap(null)
    setWindSpeed(google.maps.weather.WindSpeedUnit.KILOMETERS_PER_HOUR)
    var defaultOptions = {
    autozoom: true,
    refreshTime: 25000,
    autorefresh: true
    };
    	 function toggleClouds() {
    	 cloudLayer.setMap(cloudLayer.getMap() ? null : map);
    	 }
    	 function toggleIcons() {
    	 weatherLayer.setMap(weatherLayer.getMap() ? null : map);
    	 }
    	 function setWindSpeed(units) {
    	 weatherLayer.setOptions({'windSpeedUnits': units});
    	 }
    var options = $.extend({}, defaultOptions, acars_map_defaults);
    
    
    // They clicked the map
    google.maps.event.addListener(map, 'click', function()
    {
    clearPreviousMarkers();
    });
    
    liveRefresh();
    if(options.autorefresh == true)
    {
    setInterval(function () { liveRefresh(); }, options.refreshTime);
    }
    
    
    function liveRefresh()
    {
    $.ajax({
    type: "GET",
    url: url + "/action.php/acars/data_test",
    dataType: "json",
    cache: false,
    success: function(data)
    {
    populateMap(data);
    }
    });
    };
    
    function populateMap(data)
    {
    clearMap();
    $("#pilotlist").html("");
    
    if (data.length == 0) {
    return false;
    }
    
    var lat, lng;
    
    var details, row, pilotlink;
    var bounds = new google.maps.LatLngBounds();
    
    for (var i = 0; i < data.length; i++)
    {
    if(data[i] == null || data[i].lat == null || data[i].lng == null
    || data[i].lat == "" || data[i].lng == "") {
    continue;
    }
    
    lat = data[i].lat;
    lng = data[i].lng;
    
    
    if(i%2 == 0)
    data[i].trclass = "even";
    else
    data[i].trclass = "odd";
    
    // Pull ze templates!
    var map_row = tmpl("acars_map_row", {flight: data[i]});
    var detailed_bubble = tmpl("acars_map_bubble", {flight: data[i]});
    
    $('#pilotlist').append(map_row);
    
    var pos = new google.maps.LatLng(lat, lng);
    
    
    flightMarkers[flightMarkers.length] = new google.maps.Marker({
    position: pos,
    map: map,
    icon: url+"/lib/images/inair/"+data[i].heading+".png",
    flightdetails: data[i],
    infowindow_content: detailed_bubble
    });
    
    bounds.extend(pos);
    
    google.maps.event.addListener(flightMarkers[flightMarkers.length - 1], 'click', function()
    {
    clearPreviousMarkers();
    
    var focus_bounds = new google.maps.LatLngBounds();
    // Flight details info window
    info_window = new google.maps.InfoWindow({
    content: this.infowindow_content,
    position: this.position
    });
    
    info_window.open(map, this);
    
    // Add polyline, and start/end points
    var dep_location = new google.maps.LatLng(this.flightdetails.deplat, this.flightdetails.deplng);
    var arr_location = new google.maps.LatLng(this.flightdetails.arrlat, this.flightdetails.arrlng);
    
    
    depMarker = new google.maps.Marker({
    position: dep_location,
    map: map,
    icon: depicon,
    title: this.flightdetails.depname,
    zIndex: 100
    });
    
    
    arrMarker = new google.maps.Marker({
    position: arr_location,
    map: map,
    icon: arricon,
    title: this.flightdetails.arrname,
    zIndex: 100
    });
    
    
    // Now the flight path, if it exists
    var path = new Array();
    
    path[path.length] = dep_location;
    focus_bounds.extend(dep_location);
    
    
    path[path.length] = arr_location;
    focus_bounds.extend(this.position);
    focus_bounds.extend(arr_location);
    
    var fromAddressLat = data[i].puntirotta();
    
    
    var rotta= [
     <-----------------------------------------------------------------------------HOW TO ADD THE CONTENT OF THE FIELD "PUNTIROTTA" FROM JSON TO THE VAR "rotta"
    
    ];
    
    var something = [];
    for (var i=0; i < rotta.length; i++) {
    something.push(new google.maps.LatLng(rotta[i][0],rotta[i][1]));
    }
    
    flightPath = new google.maps.Polyline({
    path: something,
    strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2
    });
    
    map.fitBounds(focus_bounds);
    flightPath.setMap(map);
    });
    }
    
    // If they selected autozoom, only do the zoom first time
    if(options.autozoom == true && run_once == false)
    {
    map.fitBounds(bounds);
    run_once = true;
    }
    }
    
    function clearPreviousMarkers()
    {
    if(info_window)
    {
    info_window.close();
    info_window = null;
    }
    
    if(depMarker != null)
    {
    depMarker.setMap(null);
    depMarker = null;
    }
    
    if(arrMarker != null)
    {
    arrMarker.setMap(null);
    arrMarker = null;
    }
    
    if(routeMarkers.length > 0)
    {
    for(var i = 0; i < routeMarkers.length; i++) {
    routeMarkers[i].setMap(null);
    }
    }
    
    routeMarkers.length = 0;
    
    if(flightPath != null)
    {
    flightPath.setMap(null);
    flightPath = null;
    }
    }
    
    function clearMap()
    {
    if(flightMarkers.length > 0)
    {
    for(var i = 0; i < flightMarkers.length; i++) {
    flightMarkers[i].setMap(null);
    }
    }
    
    flightMarkers.length = 0;
    
    if(routeMarkers.length > 0)
    {
    for(var i = 0; i < routeMarkers.length; i++) {
    routeMarkers[i].setMap(null);
    }
    }
    
    routeMarkers.length = 0;
    }
    

  4. If you are getting that error try changing that line to;

    $pirep_xml->addChild('rawdata', serialize($pirep->rawdata));
    

    Now it seems to work, thank you very much David!

    last question When your updates are finished ranking back to normal? for example the Phoenix Virtual Airways will return the first?

  5. Hi Sammy thanks for your reply, the KVM is in the same host but the web site on KVM is very slow, you can help me? I think it's the fault of phpvms and mysql but I can not find the problem

    thanks

    Mattia

  6. Hi all

    i have a question, in my VPS with XEN, my website work perfectly but if i transfer my site in a VPS with KVM2 the site is very slow... phpvms is compatible with KVM?? you have noticed the same problem??

    Regards

    Mattia

  7. In kaCARS free dont work because in the kacars free log not have the - in the log

    [14:45] TOD Reached

    what is the code for the log kacars free? I tried this but does not work

    <?php	
    # Simple, each line of the log ends with *	   
    # Just explode and loop.
    	  $log = explode('*', $pirep->log);
    	  foreach($log as $line)		 
    	  {			 
    		    $line_items = explode(' ', $line);
    		    {
    			   if($line_items['1'] == 'TOD reached')
    			   {echo '<font color="#00FF00">'.$line.'</font><br />';}
    			   else
    			   { echo $line .'<br />';}
    		    }
    	  }
    ?>
    

×
×
  • Create New...