• Resolved billw16

    (@billw16)


    I am using trackserver for the Live Tracking option with OruxMaps and MapMyTracks. I’ve updated the infobar template as follows:
    {lat} {lon} Alt: {altitude}m Distance: {distance}m Speed: {speedmph} mph – {timestamp}

    I have 2 questions:
    1.) How would I show altitude in whole numbers (no decimals)?
    2.) How could I convert altitude to ft rather than meters?

    I can edit the code in php but just don’t know where or how exactly to do this. Can anyone help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author tinuzz

    (@tinuzz)

    The metadata is calculated and added to the server response here:

    https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L3977

    If you add new tags and want to replace them in your infobar format, you should add code for that here:

    https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.js#L333

    Does this help?

    Cheers,
    Martijn.

    Thread Starter billw16

    (@billw16)

    Awesome, thanks very much! It works great!

    I added 2 new tags for the infobar:
    {altitudeft} = Altitude in Feet
    {distancemi} = Distance in Miles

    Here are the sections of code I updated:

      trackserver.js:
    process_data: function (data, options)
            //	Added opts for altitudeft, distancemi (billw 10/11/18)
            this.set_mydata(options.div_id, options.track_id, 'altitude_ft', o.metadata.last_trkpt_altitude_ft);
            this.set_mydata(options.div_id, options.track_id, 'distance_mi', o.metadata.distance_mi);
    
    if (alltracks && alltracks[track_id])
            //	Added opts for altitudeft, distancemi (wcw 10/11/18)
            var altitude_ft = alltracks[track_id].metadata.last_trkpt_altitude_ft;
            var distance_mi = alltracks[track_id].metadata.distance_mi;
    
    if (mymapdata.infobar)
            infobar_text = infobar_text.replace(/\{altitudeft\}/gi, altitude_ft);
            infobar_text = infobar_text.replace(/\{distancemi\}/gi, distance_mi);
    
      trackserver.php:
    function get_metadata( $row, $extra_metadata = array() )
            //	Added opts for altitudeft, distancemi (billw 10/11/18)
            'last_trkpt_altitude_ft'  => number_format( (float) $row['altitude'] * 3.28084, 0),
    	'distance_mi'          => number_format( (float) $row['distance'] * 0.0006213712, 2 ),
    
    //	Added opts for altitudeft, distancemi (billw 10/11/18) (also {distance} was missing)	
    printf(
    	$format,
    	esc_html__( 'With live tracking, an information bar can be shown on the map, displaying some data from the latest trackpoint. ' .
    	'Here you can format the content of the infobar. Possible replacement tags are {lat}, {lon}, {timestamp}, {altitude}, {altitudeft}, ' .
    	'{speedms}, {speedkmh}, {speedmph}, {distance}, {distancemi}, {userid}, {userlogin}, {displayname}.', 'trackserver' )
    );
    

    If others are interested in this, perhaps you could roll it into your code when you have a chance. Thanks again for all your work on this great plugin!

    -Bill

    Plugin Author tinuzz

    (@tinuzz)

    A fix for this is now up on Github:

    https://github.com/tinuzz/wp-plugin-trackserver/commit/7d8d7634e6861b7e1c74358c6abc67835177af13

    It will be included in the 4.2 release, which I expect to do later this week.

    Best regard,
    Martijn.

    Plugin Author tinuzz

    (@tinuzz)

    Version 4.2.2 was released today. The infobar now supports the following tags:

    {lat}, {lon} – the last known coordinates
    {timestamp} – the timestamp of the last update
    {userid} – the numeric user id of the track owner
    {userlogin} – the username of the track owner
    {displayname} – the display name of the track owner
    {altitudem} – the altitude in meters
    {altitudeft} – the altitude in feet
    {speedms}, {speedms1}, {speedms2} – last known speed in m/s, with 0, 1 or 2 decimals
    {speedkmh}, {speedkmh1}, {speedkmh2} – last known speed in km/h, with 0, 1 or 2 decimals
    {speedmph}, {speedmph1}, {speedmph2} – last known speed in mi/h, with 0, 1 or 2 decimals
    {distancem} – track total distance in meters
    {distanceyd} – track total distance in yards
    {distancekm}, {distancekm1}, {distancekm2} – track total distance in km, with 0, 1 or 2 decimals
    {distancemi}, {distancemi1}, {distancemi2} – track total distance in miles, with 0, 1 or 2 decimals

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to format values for the Infobar?’ is closed to new replies.