Files
le-matelot/client/plugins/magasin/template/carte.php
2020-01-27 08:56:08 +01:00

71 lines
1.7 KiB
PHP

<?php
include_once("../Magasin.class.php");
include_once("../../../../classes/Variable.class.php");
?>
<?php
$cle = new Variable();
$cle->charger("cle_google_map");
function convert($chaine){
$avant = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñÁÂÀÅÃÄÇÉÊÈËÓÔÒØÕÖÚÛÙÜ&";
$apres = "aaaaaaooooooeeeeciiiiuuuuynaaaaaaceeeeoooooouuuu-";
$chaine = strtolower($chaine);
$chaine = strtr($chaine, $avant, $apres);
return $chaine;
}
$france = 0;
if(! $_GET['cp']){
$_GET['cp'] = "France";
$france = 1;
}
$rec = file_get_contents("http://maps.google.fr/maps/geo?q=". $_GET['cp']."&output=csv&key=" . $cle->valeur);
$coord = explode(",", $rec);
$lat = $coord[2] ;
$lon = $coord[3];
$magasin = new Magasin();
if(! $france)
$query = "select * from $magasin->table where cp=\"" . $_GET['cp'] . "\" and lat<>'' and lon<>''";
else
$query = "select * from $magasin->table";
$resul = mysql_query($query, $magasin->link);
header("Content-type: text/xml");
echo'<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<markers>';
while($row = mysql_fetch_object($resul)){
$row->adresse = convert($row->adresse);
$row->nom = convert($row->nom);
if(! $row->lat){
$row->lat = $lat;
$row->lon = $lon;
}
echo '<marker ';
echo 'id="' . $row->id . '" ';
echo 'nom="' . $row->nom . '" ';
echo 'adresse="' . $row->adresse . '" ';
echo 'cp="'. $row->cp . '" ';
echo 'ville="' . $row->ville . '" ';
echo 'tel="' . $row->tel . '" ';
echo 'fax="' . $row->tel . '" ';
echo 'lat="' . $row->lat . '" ';
echo 'lng="' . $row->lon . '" ';
echo '/>';
}
echo '</markers>';
?>