'Show real-time location

I have a web page that get locations of mobile phone.

Every time I want to see the change of the location I should make a page reload.


I want to have a refresh for the marker itself not all the page in a simple way


<?php
use App\User;
use App\Model\Proposals; // UNUSED IN THIS ISSUE SAMPLE
use App\Model\FavoriteUser;
use Carbon\Carbon;

$fav = FavoriteUser::get();
$pro = Locations::take('100')->orderBy('created_at', 'DESC')->get();
?>
<script>
    window.onload = setupRefresh;
    function setupRefresh() {
        setTimeout("refreshPage();", 15000);
    }
    function refreshPage() {
        window.location = location.href;
    }
</script>
<script>
    var locations = [
        <?php
        foreach ($pro as $s) {
            $p = $pro->where('user_id', $s->user_id)->first();
            $time1 = Carbon::now();
            $time2 = Carbon::parse($p->created_at);
            $diff = $time1->diffInMinutes($time2);

            if ($diff <= 1) {
                echo "[" . User::find($p->user_id)->customers_name . "," . $p->long . "," . $p->lat . "],";
            }
        }
        ?>
    ];
</script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source