Modification information géographique

This commit is contained in:
Michael RICOIS 2011-12-11 18:25:54 +00:00
parent a83f234821
commit b840e14894
12 changed files with 298 additions and 475 deletions

View File

@ -1,176 +0,0 @@
<?php
require_once ('geoLocalisation/geoLocalisation.lib.php');
Class GeolocalisationController extends Zend_Controller_Action
{
private $mappyVille;
private $mappyLogin = array(); // Utiliser les setter pour setter les valeurs !
public function init()
{
$this->view->headScript()
->appendFile('/themes/default/scripts/geolocalisation.js', 'text/javascript');
$this->view->headLink()
->appendStylesheet('/themes/default/styles/geolocalisation.css', 'all');
}
/**********************************************************************************/
/* Liste des établissements */
/**********************************************************************************/
/**
* Genere une sorte d'iframe pour la page liste des etablissements.
*/
public function iframeAction()
{
$listeEtablissement = $this->getRequest()->getParam('listeEtablissement');
$this->view->assign('listeEtablissement', $listeEtablissement);
}
/**
* Fonction complémentaire de iframe.
*/
public function geolistejavascriptAction()
{
$valeur = array();
$listeEtablissement = $this->getRequest()->getParam('listeEtablissement');
$geoLocalisation = new geoLocalisationLib($listeEtablissement, $valeur);
$this->view->assign('geoInformations', $valeur);
}
/**********************************************************************************/
/* Photo sur fiche identité */
/**********************************************************************************/
/**
* Netoye l'adresse des espace et des arrondissement pour paris etc... exemple "PARIS 16" devient "Paris"
* @param unknown_type $ville
*/
private function cleanAdress($ville)
{
$ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' ';
$ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => '')));
return (ucwords(strtolower($ville)));
}
/**
* Affiche la bonne photo celon si deisponnible chez Mappy sinon ont interoge google.
*/
public function geophotoAction()
{
$user = new Utilisateur();
if ($user->checkPref('mappy'))
{
self::initMappy();
$infos = $this->getRequest()->getParam('infos');
$ville = self::cleanAdress($infos->Ville);
if (in_array($ville, $this->mappyVille)) {
$source = 'mappy';
$token = self::mappyPhoto();
$this->view->assign('token', $token);
$this->view->assign('AdresseNum',$infos->AdresseNum);
$this->view->assign('AdresseRue', $infos->AdresseRue);
$this->view->assign('AdresseVille', $infos->Ville);
}
else {
$source = 'google';
self::googlePhoto();
}
$this->view->assign('source', $source);
} else {
$this->view->assign('disable', true);
}
}
/**********************************************************************************/
/* Mappy sur fiche identité */
/**********************************************************************************/
public function setMappyLogin($login)
{
$this->mappyLogin['login'] = $login;
}
public function setMappyPassword($password)
{
$this->mappyLogin['password'] = $password;
}
/**
* Initialisation des villes disponnible chez mappy
*/
private function initMappy()
{
self::setMappyLogin('scoresdecisions');
self::setMappyPassword('g1nq3iKv');
$this->mappyVille = array(
'Bordeaux', 'Caen' , 'Cannes',
'Grenoble', 'La Baule', 'Lille',
'Lyon', 'Marseille', 'Montpellier',
'Nancy', 'Nantes', 'Nice',
'Rennes', 'Strasbourg', 'Toulouse',
'Asnières-sur-Seine', 'Boulogne-Billancourt', 'Courbevoie',
'Issy-les-Moulineaux', 'Levallois-Perret',
'Montrouge', 'Nanterre', 'Neuilly-sur-Seine',
'Rueil-Malmaison', 'Sèvres', 'Versailles',
'Paris'
);
}
/**
* Génère le toker pour mappy.
*/
private function getToken()
{
$ACCESSOR_URL = 'http://axe.mappy.com/1v1/';
$timestamp = time();
$hash = md5($this->mappyLogin['login']."@".$this->mappyLogin['password']."@".$timestamp);
$preToken = $this->mappyLogin['login']."@".$timestamp."@".$hash;
$urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]);
$fh = @fopen($urlGetToken, 'rb');
if ($fh == false) return false;
$token = '';
while (!feof($fh))$token .= fread($fh, 8192);
fclose($fh);
return ($token);
}
/**
* Apelle le token
*/
public function mappyPhoto()
{
if(!($token = self::getToken())) {
echo 'Impossible de recuperer le Token !';
}
return($token);
}
/**********************************************************************************/
/* Google sur fiche identité */
/**********************************************************************************/
/**
* Genere le code pour l'image google.
*/
public function googlePhoto()
{
$googleKey = geoLocalisationLib::getGoogleKey($_SERVER['SERVER_NAME']);
$adress = array();
$request = $this->getRequest();
$info = $request->getParam('infos');
$google_map = 'http://maps.google.fr/maps?f=q&hl=fr&geocode=&q='.
$info->AdresseNum.',+'.
urlencode($info->AdresseVoie).'+'.
urlencode(htmlspecialchars_decode($info->AdresseRue, ENT_QUOTES)).
',+'.$info->CP.'+'.
urlencode($info->Ville);
$this->view->assign('infos', $info);
$this->view->assign('google_map_link', $google_map);
$this->view->assign('googleKey', $googleKey);
}
}

View File

@ -738,4 +738,57 @@ class IdentiteController extends Zend_Controller_Action
}
}
public function geoAction()
{
$this->view->headScript()->appendFile('/themes/default/scripts/geolocalisation.js', 'text/javascript');
$this->view->headLink()->appendStylesheet('/themes/default/styles/geolocalisation.css', 'all');
$infos = $this->getRequest()->getParam('infos');
$user = new Utilisateur();
$this->view->assign('facadeDisable', $user->checkPref('mappy'));
require_once 'Scores/Google.php';
$google = new Google();
$decLat = $google->dec2dms($infos->GeoLat);
$decLon = $google->dec2dms($infos->GeoLon);
$mapsHref = $google->getGoogleMapLink(urlencode(
$infos->AdresseNum.', '.$infos->AdresseVoie.' '.
htmlspecialchars_decode($infos->AdresseRue, ENT_QUOTES).
', '.$infos->CP.' '.$infos->Ville));
$this->view->assign('mapsHref', $mapsHref);
$this->view->assign('decLat', $decLat);
$this->view->assign('decLon', $decLon);
$this->view->assign('infos', $infos);
}
public function facadeAction()
{
require_once 'Scores/Mappy.php';
$infos = $this->getRequest()->getParam('infos');
$mappy = new Mappy();
if ($mappy->villeCouverte($infos->Ville))
{
$this->view->assign('source', 'mappy');
$this->view->assign('lienJs',$mappy->getJs());
$this->view->assign('AdresseNum',$infos->AdresseNum);
$this->view->assign('AdresseRue', $infos->AdresseRue);
$this->view->assign('AdresseVille', $infos->Ville);
}
else
{
require_once 'Scores/Google.php';
$google = new Google();
$googleKey = $google->getGoogleKey($_SERVER['SERVER_NAME']);
$this->view->assign('googleKey', $googleKey);
$this->view->assign('source', 'google');
$this->view->assign('AdresseNum',$infos->AdresseNum);
$this->view->assign('AdresseRue', $infos->AdresseRue);
$this->view->assign('AdresseVille', $infos->Ville);
$this->view->assign('infos', $infos);
}
}
}

View File

@ -1,42 +0,0 @@
<?php echo $this->geoInformations[0][0];?>
<html>
<head>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&region=FR"></script>
<script type="text/javascript">
function chargeCarte() {
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(<?php echo $this->geoInformations[0]['coordonnees'][1];?>,
<?php echo $this->geoInformations[0]['coordonnees'][0];?>),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('carte'), myOptions);
<?php for ($i = 0; $i < count($this->geoInformations); $i++) { ?>
<?php if (!empty($this->geoInformations[$i]['coordonnees'][0]) and !empty($this->geoInformations[$i]['coordonnees'][1])):?>
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(<?php echo $this->geoInformations[$i]['coordonnees'][1];?>,
<?php echo $this->geoInformations[$i]['coordonnees'][0];?>),
title: "<?php echo $this->geoInformations[$i]['title'];?>"
});
google.maps.event.addListener(marker, 'click', function() {
var infowindow = new google.maps.InfoWindow({
content: "<?php echo $this->geoInformations[$i]['content'];?>"
});
var pos = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $this->geoInformations[$i]['coordonnees'][1];?>,
<?php echo $this->geoInformations[$i]['coordonnees'][0];?>)
});
infowindow.open(map, pos);
});
<?php endif; ?>
<?php } ?>
}
</script>
</head>
<body onload="javascript:chargeCarte()">
<div id="carte" style="width:500px;height:500px"></div>
</body>
</html>

View File

@ -1,127 +0,0 @@
<h2>Localisation géographique</h2>
<div class="paragraph">
<div id="infogeo" class="clearfix">
<div id="infogeo_txt">
<span id=geolocalisation>
<b>Information géographique :</b><br/>
Latitude : <?php echo geoLocalisationLib::dec2dms($this->infos->GeoLat)?> (<?php echo $this->infos->GeoLat;?>)<br />
Longitude : <?php echo geoLocalisationLib::dec2dms($this->infos->GeoLon)?> (<?php echo $this->infos->GeoLon;?>)<br />
</span>
<a id="lien-google" href="<?php echo $this->google_map_link;?>" target="_blank">
Afficher l&#039;adresse sur Google Map &copy;</a><br/>
<br/>
<b>Code commune / Rivoli :</b><br/>
<?php print $this->infos->Dept.' '.$this->infos->codeCommune.' / '.$this->infos->Rivoli; ?>
<?php
if (count($this->infos->InfosIris)>0){
$InfosIris = $this->infos->InfosIris;
$codComIris = str_replace($InfosIris->codIris, '', $InfosIris->codComIris);
?>
<br/><br/><b>Iris :</b>
<?php
if ($InfosIris->codIris*1 == 0){
?>
<br/>Commune non découpée en Iris
<?php } else {?>
<br/>Code : <?=$codComIris?> <?=$InfosIris->codIris?>
<br/>Libellé : <a title="Consulter le plan d'assemblage de la commune" href="<?=$this->url(array('controller'=>'identite', 'action'=>'iris', 'code'=>$codComIris), null, true)?>" target="_blank"><?=$InfosIris->libIris?></a>
<img title="<?=$InfosIris->typIris?>" style="vertical-align:middle;" src="/themes/default/images/info.gif">
<?php }?>
<?php }?>
</div>
<?php if(!$this->disable):?>
<?php if ($this->source == 'google'):?>
<div id="infogeo_photo">
<div id="legende-photo" style="display: block;">
Cliché à l'approche de l'adresse postale.
</div>
<div>
<img id="pp-cb-thumb" src="http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll=<?php echo $this->infos->GeoLat.','.$this->infos->GeoLon?>" width="300px" height="128px" />
</div>
</div>
<script type="text/javascript"
src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $this->googleKey;?>">
</script>
<script type="text/javascript">
function affichePhoto() {
<?php
if ($this->infos->GeoPrecis < 7) {
print 'var geoCoder = new GClientGeocoder;';
print 'geoCoder.getLocations("'.
$this->infos->AdresseNum.' '.
$this->infos->AdresseRue.' '.
$this->infos->CP.' '.
$this->infos->Ville.'", geoCodeCB);';
} else {
print 'var ll = new GLatLng('.$this->infos->GeoLat.', '.$this->infos->GeoLon.');';
print 'doShowPanoData(ll);';
}
?>
}
function geoCodeCB(reponse) {
if (reponse &&
reponse.Status.code == 200 &&
reponse.Placemark.length == 1 &&
reponse.Placemark[0].AddressDetails.Accuracy > 5) {
var lat = reponse.Placemark[0].Point.coordinates[1];
var lon = reponse.Placemark[0].Point.coordinates[0];
var ll = new GLatLng(lat, lon);
$("#geolocalisation").
replaceWith("<b>Information géographique :</b><br/>" +
"Latitude : " + lat + "<br/>" +
"Longitude : " + lon + "<br/>"
);
$("#lien-google").
replaceWith(
"<a href=http://maps.google.fr/maps?q=" +
"<?php echo $this->info->AdresseNum.'+'.$this->infos->AdresseRue.'+'.
$this->infos->CP.'+'.$this->infos->Ville;?>" +
" target=_blank>" +
"Afficher l'adresse sur Google Map &copy;</a>"
);
doShowPanoData(ll);
}
}
$(document).ready(function() {
if ($('#pp-cb-thumb').length) {
affichePhoto();
}
});
</script>
<?php elseif ($this->source == 'mappy'):?>
<div>
<img id="pp-cb-thumb" width="300px" />
</div>
<script src="http://axe.mappy.com/1v1/init/get.aspx?auth=<?php echo $this->token;?>&version=2.01&solution=ajax"></script>
<script type="text/javascript">
$(document).ready(function() {
var photoService = new Mappy.api.visiocity.PhotoService();
var geo = new Mappy.api.geolocation.Geocoder();
var address = "<?php echo $this->AdresseNum;?> <?php echo $this->AdresseRue;?> <?php echo $this->AdresseVille;?>";
geo.geocode(address,
function(result) {
photoService.search(result[0], "f", serviceHandler);
},
function(error) {
});
var serviceHandler = function(result) {
if (result instanceof Mappy.api.visiocity.Frontage) {
var current = result.getCurrent();
var img = $('<img src="' + current.getURL(320, null) +
'" alt="' + current.getDescription() +
'" width="300px" />');
$('#pp-cb-thumb').replaceWith(img);
}
}
}
);
</script>
<?php endif;?>
<?php endif;?>
</div>
</div>

View File

@ -1 +0,0 @@
<?php echo $this->action('geolistejavascript', 'geolocalisation', null, array('listeEtablissement' => $this->listeEtablissement));?>

View File

@ -0,0 +1,80 @@
<?php if ($this->source == 'google'):?>
<div id="infogeo_photo">
<div id="legende-photo" style="display: block;">
Cliché à l'approche de l'adresse postale.
</div>
<div>
<img id="pp-cb-thumb" src="http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll=<?=$this->infos->GeoLat.','.$this->infos->GeoLon?>" width="300px" height="128px" />
</div>
</div>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=<?=$this->googleKey?>"></script>
<script type="text/javascript">
function affichePhoto() {
<?php if ($this->infos->GeoPrecis < 7) {?>
var geoCoder = new GClientGeocoder;
geoCoder.getLocations("<?=$this->infos->AdresseNum.' '.
$this->infos->AdresseRue.' '.
$this->infos->CP.' '.
$this->infos->Ville?>", geoCodeCB);
<?php } else { ?>
var ll = new GLatLng(<?=$this->infos->GeoLat?>, <?=$this->infos->GeoLon?>);
doShowPanoData(ll);
<?php } ?>
}
function geoCodeCB(reponse) {
if (reponse &&
reponse.Status.code == 200 &&
reponse.Placemark.length == 1 &&
reponse.Placemark[0].AddressDetails.Accuracy > 5) {
var lat = reponse.Placemark[0].Point.coordinates[1];
var lon = reponse.Placemark[0].Point.coordinates[0];
var ll = new GLatLng(lat, lon);
$("#geolocalisation").
replaceWith("<b>Information géographique :</b><br/>" +
"Latitude : " + lat + "<br/>" +
"Longitude : " + lon + "<br/>"
);
$("#lien-google").
replaceWith(
"<a href=http://maps.google.fr/maps?q=" +
"<?=$this->info->AdresseNum.'+'.$this->infos->AdresseRue.'+'.
$this->infos->CP.'+'.$this->infos->Ville?>" +
" target=_blank>" +
"Afficher l'adresse sur Google Map &copy;</a>"
);
doShowPanoData(ll);
}
}
$(document).ready(function() {
if ($('#pp-cb-thumb').length) {
affichePhoto();
}
});
</script>
<?php elseif ($this->source == 'mappy'):?>
<div><img id="pp-cb-thumb" width="300px" /></div>
<script src="<?=$this->lienJs?>"></script>
<script type="text/javascript">
$(document).ready(function() {
var photoService = new Mappy.api.visiocity.PhotoService();
var geo = new Mappy.api.geolocation.Geocoder();
var address = "<?=$this->AdresseNum?> <?=$this->AdresseRue?> <?=$this->AdresseVille?>";
geo.geocode(address, function(result) {
photoService.search(result[0], "f", serviceHandler);
}, function(error) {});
var serviceHandler = function(result) {
if (result instanceof Mappy.api.visiocity.Frontage) {
var current = result.getCurrent();
var img = $('<img src="' + current.getURL(320, null) +
'" alt="' + current.getDescription() +
'" width="300px" />');
$('#pp-cb-thumb').replaceWith(img);
}
}
});
</script>
<?php endif;?>

View File

@ -82,7 +82,7 @@ echo $this->partial('identite/fiche-item.phtml', $this->dBlock['EffectifEtab']);
</div>
<?php if (empty($this->AutrePage)):?>
<?=$this->action('geophoto', 'geolocalisation', null, array('infos' => $this->infos));?>
<?=$this->action('geo', 'identite', null, array('infos' => $this->infos));?>
<?=$this->action('news', 'identite');?>
<?php endif;?>

View File

@ -0,0 +1,37 @@
<h2>Localisation géographique</h2>
<div class="paragraph">
<div id="infogeo" class="clearfix">
<div id="infogeo_txt">
<span id=geolocalisation>
<b>Information géographique :</b><br/>
Latitude : <?=$this->decLat?> (<?=$this->infos->GeoLat?>)<br />
Longitude : <?=$this->decLon?> (<?=$this->infos->GeoLon?>)<br />
</span>
<a id="lien-google" href="<?=$this->mapsHref?>" target="_blank">
Afficher l&#039;adresse sur Google Map &copy;</a><br/>
<br/>
<b>Code commune / Rivoli :</b><br/>
<?php print $this->infos->Dept.' '.$this->infos->codeCommune.' / '.$this->infos->Rivoli; ?>
<?php
if (count($this->infos->InfosIris)>0){
$InfosIris = $this->infos->InfosIris;
$codComIris = str_replace($InfosIris->codIris, '', $InfosIris->codComIris);
?>
<br/><br/><b>Iris :</b>
<?php
if ($InfosIris->codIris*1 == 0){
?>
<br/>Commune non découpée en Iris
<?php } else {?>
<br/>Code : <?=$codComIris?> <?=$InfosIris->codIris?>
<br/>Libellé : <a title="Consulter le plan d'assemblage de la commune" href="<?=$this->url(array('controller'=>'identite', 'action'=>'iris', 'code'=>$codComIris), null, true)?>" target="_blank"><?=$InfosIris->libIris?></a>
<img title="<?=$InfosIris->typIris?>" style="vertical-align:middle;" src="/themes/default/images/info.gif">
<?php }?>
<?php }?>
</div>
<?php if($this->facadeDisable):?>
<?=$this->action('facade', 'identite', null, array('infos' => $this->infos));?>
<?php endif;?>
</div>
</div>

49
library/Scores/Google.php Normal file
View File

@ -0,0 +1,49 @@
<?php
class Google
{
protected $url = 'http://maps.google.fr/maps?f=q&hl=fr&geocode=&q=';
protected $urlPhoto = '';
public function getGoogleKey($domain)
{
switch ($domain) {
case 'extranet.sd.dev':
return 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTTQao-JYbZvohjws19Eq-s8HocrxTKnnmfOnWxcHe01UHRIkRkZ1f17Q';
break;
case 'extranet.sd.lan':
return 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRSKTEtsiH12Xc5SNL4Zmo_wRXVkrxR4jPIy3GOKGzZxBEOkvOsLG2CJ3w';
break;
case 'extranet-2.0.sd.lan':
return 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTy4fRlC-SwcCZRiggZoieobzFAiRR6bORav5_Dl3324CqVALrh-ciGFQ';
break;
case 'extranetrec.scores-decisions.com':
return 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRQQcNgS-tLiAG-ic2CW9PypgC_xRhTjSL9-5iBPvj3GA1_AvZYQU_QR3Q';
break;
case 'extranet.scores-decisions.com':
return 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRQvADPcxwXf3Q2QIE-M32vuSkrxiBRLUHDB_YSLeTscTDeWRKM_wILaaw';
break;
}
}
protected function supprDecimales($dec)
{
if ($dec>0 )
return floor($dec);
else
return ceil($dec);
}
public function dec2dms($dec)
{
$d = $this->supprDecimales($dec);
$m = $this->supprDecimales(($dec - $d) * 60);
$s = abs(round(((($dec - $d) * 60) - $m) * 60));
$m = abs($m);
return $d.'°'.$m."'".$s.'"';
}
public function getGoogleMapLink($q)
{
return $this->url.$q;
}
}

76
library/Scores/Mappy.php Normal file
View File

@ -0,0 +1,76 @@
<?php
class Mappy
{
protected $login = 'scoresdecisions';
protected $password = 'g1nq3iKv';
protected $villes = array(
'BORDEAUX',
'CAEN' ,
'CANNES',
'GRENOBLE',
'LA BAULE',
'LILLE',
'LYON',
'MARSEILLE',
'MONTPELLIER',
'NANCY',
'NANTES',
'NICE',
'RENNES',
'STRASBOURG',
'TOULOUSE',
'ASNIERES-SUR-SEINE',
'BOULOGNE-BILLANCOURT',
'COURBEVOIE',
'ISSY-LES-MOULINEAUX',
'LEVALLOIS-PERRET',
'MONTROUGE',
'NANTERRE',
'NEUILLY-SUR-SEINE',
'RUEIL-MALMAISON',
'SEVRES',
'VERSAILLES',
'PARIS'
);
public function getToken()
{
$ACCESSOR_URL = 'http://axe.mappy.com/1v1/';
$timestamp = time();
$hash = md5($this->login."@".$this->password."@".$timestamp);
$preToken = $this->login."@".$timestamp."@".$hash;
$urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]);
$fh = @fopen($urlGetToken, 'rb');
if ($fh == false) return false;
$token = '';
while (!feof($fh))$token .= fread($fh, 8192);
fclose($fh);
return ($token);
}
protected function cleanAdress($ville)
{
$ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' ';
$ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => '')));
return (ucwords(strtolower($ville)));
}
public function villeCouverte($ville)
{
$ville = $this->cleanAdress($ville);
if (in_array(strtoupper($ville),$this->villes)){
return true;
}
return false;
}
public function getJs()
{
$token = $this->getToken();
$href = 'http://axe.mappy.com/1v1/init/get.aspx?auth='.$token.'&version=2.01&solution=ajax';
return $href;
}
}

View File

@ -1,126 +0,0 @@
<?php
require_once ('common/curl.php');
Class geoLocalisationLib
{
public $googleKey;
public $googleUrl = 'http://maps.google.com/maps/geo?q=';
public function __construct($listeEtablissement, &$valeur)
{
$valeur = self::createListeOfAdress($listeEtablissement);
}
public function getGoogleKey($domaineName)
{
switch ($domaineName) {
case 'extranet.sd.dev':
return ($this->googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTTQao-JYbZvohjws19Eq-s8HocrxTKnnmfOnWxcHe01UHRIkRkZ1f17Q');
case 'extranet.sd.lan':
return ($this->googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRSKTEtsiH12Xc5SNL4Zmo_wRXVkrxR4jPIy3GOKGzZxBEOkvOsLG2CJ3w');
case 'extranet-2.0.sd.lan':
return ($this->googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTy4fRlC-SwcCZRiggZoieobzFAiRR6bORav5_Dl3324CqVALrh-ciGFQ');
default:
return (false);
}
return ($this->googleKey);
}
/**
* Execute une requete cURL pour recuperer les infos XML
* Traitement XML avec SimpleXml.
*
* @param marqueur bien formaté $marqueur
*/
public function getCoordinates($marqueur)
{
// Pour les appelles statics. version dev pour la clef.
(isset($this->googleKey))?$googleKey = $this->googleKey:$googleKey = 'ABQIAAAAuKBtUyFonYJBl1fqfc78tRTTQao-JYbZvohjws19Eq-s8HocrxTKnnmfOnWxcHe01UHRIkRkZ1f17Q';
(isset($this->googleUrl))?$googleUrl = $this->googleUrl:$googleUrl = 'http://maps.google.com/maps/geo?q=';
$sep = ',';
$cURL = curl_init();
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
$Url = $googleUrl . urlencode(
$marqueur['adresse'].$sep.$marqueur['cp'].
$sep.$marqueur['ville'].$sep.$marqueur['pays']).'&output=xml&key='.$googleKey;
curl_setopt($cURL, CURLOPT_URL, $Url);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($cURL, CURLOPT_USERAGENT, $user_agent);
$data = curl_exec($cURL);
curl_close($cURL);
if (isset($data) and !empty($data)) {
$xml = new SimpleXMLElement($data);
$result = simplexml_load_string($data);
$explode = explode(',' ,$result->Response->Placemark->Point->coordinates);
if (count($explode) == 3)
$coordinates = $explode;
else
$coordinates = false;
} else
$coordinates = false;
return ($coordinates);
}
public function getImage($coordonnees)
{
$image = 'http://cbk0.google.com/cbk?output=thumbnail&w=300&h=234&ll=';
return ($image.$coordonnees[1].','.$coordonnees[0]);
}
public function supprDecimales($dec)
{
if ($dec>0 )
return floor($dec);
else
return ceil($dec);
}
public function dec2dms($dec)
{
$d = self::supprDecimales($dec);
$m = self::supprDecimales(($dec - $d) * 60);
$s = abs(round(((($dec - $d) * 60) - $m) * 60));
$m = abs($m);
return $d.'°'.$m."'".$s.'"';
}
/**en cours **/
protected function createListeOfAdress($listeEtablissement)
{
$coordonnes = array();
$i = 0;
$image = 'http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll=';
foreach ($listeEtablissement->result->item as $etablissement)
{
$search = array();
$search['adresse'] = str_replace(' ', '+', $etablissement->Adresse);
$search['cp'] = str_replace(' ', '+', $etablissement->CP);
$search['ville'] = str_replace(' ', '+', $etablissement->Ville);
$search['pays'] = 'France';
$valeur = self::getCoordinates($search);
if ($valeur!=false) {
$coordonnes[$i]['coordonnees'] = $valeur;
$coordonnes[$i]['title'] = $etablissement->Enseigne;
$coordonnes[$i]['content'] = 'Etablissement : '.$etablissement->Nic.'<br />'.
$etablissement->Adresse.'<br />'.
'<b>'.$etablissement->CP.' '.$etablissement->Ville.'</b><br />'.
$etablissement->Pays.'<br />'.'<img src=\''.$image.$valeur[1].','.$valeur[0].'\' />'.'<br />'.
$etablissement->NafEtab.' : '.$etablissement->NafEtabLib;
}
$i++;
}
return ($coordonnes);
}
}

View File

@ -1,7 +1,7 @@
#infogeo_txt {
float:left;
width:250px;
padding:20px 0 0 20px;
padding:10px 0;
}
#infogeo_photo {