2

My android app will send the name,mobile number,latitude and longitude values (for every 15 minutes)to the database(image provided).

Using that values I need to show the path on google map on a "WEB PAGE".The database maintains more than one person location details.

So,I've created a dropdown where we need to select the name and search which will give the path of that particular person.

Here my code snippet goes:

<!DOCTYPE html>

<html dir="***" id="******">

<head>

    <?php include_once "title.php"; ?>

    <!--Map Script Starts Here-->

        <script type="text/javascript" src="https://www.google.com/jsapi"></script>

        <script type="text/javascript">

            google.load("visualization", "1", {packages:["map"]});

            google.setOnLoadCallback(drawChart);

            function drawChart() {

                var data = google.visualization.arrayToDataTable([

                    ['Lat', 'Long', 'Name'],

                    <?php

                        $query = "SELECT DISTINCT * FROM information ORDER BY id DESC ";        

                        $result = $dbConnection->prepare($query);

                        $result->execute();                                     

                        if($result->rowCount() >0)

                        {

                            $num = $result->rowCount();

                            while($row = $result->fetch())

                            {

                                $mobile = $row['mobile'];

                                $latitude = $row['latitude'];

                                $longitude = $row['longitude'];



                                $query1 = "SELECT * FROM information WHERE mobile=? ORDER BY id DESC";      

                                $result1 = $dbConnection->prepare($query1);

                                $result1->execute(array($mobile));      

                                $row1 = $result1->fetch();

                                $cname = $row1['name'];



                                echo "[$latitude, $longitude, '$cname'],";  

                            }

                        }

                    ?>

                ]);

                var map = new google.visualization.Map(document.getElementById('map_div'));

                map.draw(data, {showTip: true, enableScrollWheel: true, useMapTypeControl: true});

            }

        </script>

    <!--Map Script Ends Here-->

</head>

This code is not fulfilling the requirement

Outputthis is what i get

how to draw path among these points

Database:

my database

If I use poly lines it is drawing a line but i need the pathI don't want this

Prabs
  • 4,923
  • 6
  • 38
  • 59

1 Answers1

0

To draw a path you have to get quite precise coordinates of the locations. For coordinates separated far apart the Google Maps API will end up drawing a straight line.

To write the android code of that type you have to register the location change of your users at every 30 mins so that it does not drain the battery or you can add a min distance to last location sort of check. So that you get a precise location.

Rest of the pieces in your code looks fine (Storing the lat lang in database and then retrieving from the PHP script).

For more Code implementation follow this link.

Hope this Help!!

Community
  • 1
  • 1
AniV
  • 3,997
  • 1
  • 12
  • 17
  • 1
    Thank you @AniV...but the link that u have provided deals with draw path in android app..but as I mentioned am doing this in a web page..using php..and regarding the example,just for the clear image I've used far locations..Actually in these days I found some thing on net.. this link http://jsfiddle.net/4u9xbsnu/# can you guide me in passing the database values to it instead of manual values – Prabs Feb 09 '15 at 04:30