function _show_loan_on_map($loan)
{
    list($lat, $lon) = split(' ', $loan['location']['geo']['pairs']);
    $country = $loan['location']['country'];
    $city = $loan['location']['town'];
    ?>

  <map-point>
  <location>
    <latitude><?php 
    echo $lat;
    ?>
</latitude>
    <longitude><?php 
    echo $lon;
    ?>
</longitude>
    <city><?php 
    echo $city;
    ?>
</city>
    <country><?php 
    echo $country;
    ?>
</country>
  </location>
<?php 
    _show_loan($loan);
    ?>
  </map-point>
<?php 
}
}
//echo $query_params;
$json_request_url = "http://api.kivaws.org/v1/loans/search.json?{$query_params}";
// echo "$request_url\n\n";
$json_response = file_get_contents($json_request_url);
include 'json_error_handling.php';
$json_decoded = json_decode($json_response, true);
//print_r($json_decoded);
?>

<module>
  <header layout="simple">
    <layout-items>
      <block class="title">Search results</block>
    </layout-items>
  </header>

<?php 
foreach ($json_decoded['loans'] as $loan) {
    //print_r($loan);
    // echo "/loan_detail?show=$load_id";
    // http://kiva.org/app.php?page=businesses&action=about&id=<id>
    // http://www.kiva.org/img/80w80h/<id>.jpg
    _show_loan($loan);
}
?>

</module>

<?php 
include 'bpxml-footer.php';