Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Select specific category by writing PHP code to show lat & lng location in google map using volley library

    • 0
    • 0
    • 0
    • 3
    • 0
    • 0
    • 0
    • 401
    Answer it

    I want to display location (lat & lng) markers in Android google map using volley library by selecting the category.

    I am not able to get individual selected item locations but I am able to get all locations markers in map. Please help in code!

    The link for my detail code : http://stackoverflow.com/questions/33339535/how-to-select-specific-category-in-spinner-to-show-lat-lng-location-in-google

 3 Answer(s)

  • Devesh,

     Treeid   treelatitude  treelongitude  treeCondition
    
       1        12.33         17.22           Balanced
       2       12.33          17.22           Healthy
       3       12.33          17.33           Dieseased
       4       13.44          17.55           Healthy
       5       11.32          17.66           Imbalanced
       6       12.33          18.33           Healthy
       7       14.44          18.44           Healthy
       8       11.22          17.22           Balanced
    

    I have slightly made changes in my code pl follow: I am able to get "Healthy" but If I select "Balanced" it should show only Balanced treeid & lat , long

      <?php
    
      define('&#95;&#95;ROOT&#95;&#95;', dirname(dirname(&#95;&#95;FILE&#95;&#95;))); 
    require&#95;once(&#95;&#95;ROOT&#95;&#95;.'/public&#95;html/Config.php');
    
    
     // Connecting to mysql database
        $mysqli = new mysqli(DB&#95;HOST, DB&#95;USER, DB&#95;PASSWORD, DB&#95;DATABASE);
    
       // json response array
       $response = array();
    
    
    $sq = "SELECT treeid, treelatitude, treelongitude FROM tree WHERE (treecondition = 'Healthy','Balanced')";
    
      if (isset($&#95;POST['treecondition'])) {
    
    // receiving the post params
    
     $treecondition = $&#95;POST['treecondition'];
    
    // get the tree details for google map marker
    if($stmt = $mysqli->query($sq)){
    
       if ($stmt->num&#95;rows) {
    
    
           while($tree = $stmt->fetch&#95;assoc()) {
    
            $treeItem = array();
    
            $treeItem["treeid"] = $tree['treeid'];
            $treeItem["treelatitude"] = $tree['treelatitude'];
            $treeItem["treelongitude"] = $tree['treelongitude'];
            $response[] = $treeItem;
    
     }  echo json&#95;encode($response);
    
      }
    
      }else {
         // user is not found with the credentials
     $response["error"] = TRUE;
     $response["error&#95;msg"] = "Tree list view credentials are wrong. Please try again!";
     echo json&#95;encode($response);
      }
      $mysqli->close();
     }
    
  • Devesh,

    This is what I am getting!

    http://plantnow.net16.net/googlemaplocations.php

    [{"treeid":"2","treespecies":"Hatti","treelatitude":"5.5","treelongitude":"5.5"},{"treeid":"1","treespecies":"Kattoda","treelatitude":"15.4030008","treelongitude":"75.0770729"},{"treeid":"99","treespecies":"Halasu","treelatitude":"0","treelongitude":"0"},{"treeid":"21","treespecies":"Sita-Asoka","treelatitude":"15.4037277","treelongitude":"75.0764234"},{"treeid":"3","treespecies":"Nerale","treelatitude":"15.4584114","treelongitude":"74.9921761"},{"treeid":"4","treespecies":"Basavanapada","treelatitude":"15.4584057","treelongitude":"74.992166"}]

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: