New code for google maps
This commit is contained in:
parent
e887a32b3d
commit
2e828add07
@ -160,7 +160,7 @@ class IdentiteController extends Zend_Controller_Action
|
||||
'label' => 'Logo',
|
||||
'texte' => $logo->affiche(),
|
||||
);
|
||||
|
||||
|
||||
$this->view->assign('exportObjet', $infos);
|
||||
$this->view->assign('dBlock', $dBlock);
|
||||
$this->view->assign('logo', $logoImg);
|
||||
@ -372,85 +372,55 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$marqueurs = array();
|
||||
|
||||
$j = 0;
|
||||
foreach ($etabs as $i => $etab) {
|
||||
|
||||
if ($etab->Siege == 1) {
|
||||
$type = 'Siège ';
|
||||
} else {
|
||||
$type = 'Etablissement ';
|
||||
}
|
||||
if ($etab->Actif == 1) {
|
||||
$type .= 'actif';
|
||||
} else {
|
||||
$type .= 'inactif';
|
||||
}
|
||||
$type .= ' - '.$etab->NafEtabLib;
|
||||
|
||||
$titre = "$siren ".$etab->Nic." : $type<br/>";
|
||||
if ($etab->Enseigne <> '') {
|
||||
$titre .= 'Enseigne : '.$etab->Enseigne.'<br/>';
|
||||
}
|
||||
|
||||
$texte = '';
|
||||
$texte .= 'Etablissement : '.$etab->Nic.'<br/>';
|
||||
$texte .= $etab->Adresse.'<br/>';
|
||||
$adresse = $etab->Adresse.' ';
|
||||
if ($etab->Adresse2 <> '') {
|
||||
$texte .= $etab->Adresse2.'<br/>';
|
||||
if (strlen(trim($adresse)) < 7) {
|
||||
$adresse = $etab->Adresse2.' ';
|
||||
if ( count($etabs)>0 ) {
|
||||
foreach ($etabs as $i => $etab)
|
||||
{
|
||||
if ($etab->Siege == 1) {
|
||||
$type = 'Siège ';
|
||||
} else {
|
||||
$type = 'Etablissement ';
|
||||
}
|
||||
}
|
||||
$texte.='<b>'.$etab->CP.' '.$etab->Ville.'</b><br/>';
|
||||
if ($etab->Actif == 1) {
|
||||
$type .= 'actif';
|
||||
} else {
|
||||
$type .= 'inactif';
|
||||
}
|
||||
$type .= ' - '.$etab->NafEtabLib;
|
||||
|
||||
require_once 'Scores/classMMap.php';
|
||||
$mmap = new MMap($adresse, $etab->CP, $etab->Ville);
|
||||
if ($mmap->latitudeDec == '') {
|
||||
continue;
|
||||
}
|
||||
$photo = 'http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll='.
|
||||
$mmap->latitudeDec.','.
|
||||
$mmap->longitudeDec;
|
||||
$titre = "$siren ".$etab->Nic." : $type<br/>";
|
||||
if ($etab->Enseigne <> '') {
|
||||
$titre .= 'Enseigne : '.$etab->Enseigne.'<br/>';
|
||||
}
|
||||
|
||||
$adresse .= $etab->CP.' '.$etab->Ville;
|
||||
$texte = '';
|
||||
$texte .= 'Etablissement : '.$etab->Nic.'<br/>';
|
||||
$texte .= $etab->Adresse.'<br/>';
|
||||
$adresse = $etab->Adresse.' ';
|
||||
if ($etab->Adresse2 <> '') {
|
||||
$texte .= $etab->Adresse2.'<br/>';
|
||||
if (strlen(trim($adresse)) < 7) {
|
||||
$adresse = $etab->Adresse2.' ';
|
||||
}
|
||||
}
|
||||
$adresse .= $etab->CP.' '.$etab->Ville;
|
||||
$texte.='<b>'.$etab->CP.' '.$etab->Ville.'</b><br/>';
|
||||
$texte .= '</a>';
|
||||
$texte .= '<br/>';
|
||||
$texte .= '<i>'.$etab->NafEtab.' : '.$etab->NafEtabLib.'</i>';
|
||||
|
||||
$google_map = 'http://maps.google.fr/maps?q='.urlencode($adresse);
|
||||
$icone = 'http://'.$_SERVER['SERVER_NAME'].'/themes/default/images/maps/'.$this->iconeDuMarqueur($etab->NafEtab, $etab->Siege, $etab->Actif);
|
||||
|
||||
$texte .= '<a href='.$google_map.' target=_blank>';
|
||||
if ($mmap->precision >= 7 && @fopen($photo, 'r') != false) {
|
||||
$texte .= '<img src='.$photo.' width=\"155\" height=\"74\" />';
|
||||
} else {
|
||||
$texte .= 'Afficher l\'adresse sur Google Map ©';
|
||||
}
|
||||
$texte .= '</a>';
|
||||
$texte .= '<br/>';
|
||||
$texte .= '<i>'.$etab->NafEtab.' : '.$etab->NafEtabLib.'</i>';
|
||||
|
||||
$icone = 'http://'.$_SERVER['SERVER_NAME'].'/themes/default/images/maps/'.$this->iconeDuMarqueur($etab->NafEtab, $etab->Siege, $etab->Actif);
|
||||
|
||||
$marqueurs[$j] = array($mmap->latitudeDec, $mmap->longitudeDec, $titre, $texte, $type, $icone);
|
||||
++$j;
|
||||
// if ($j >= 30) { // Limitation du nombre d'etablissements sur la carte
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
if (count($marqueurs) > 1) {
|
||||
$min_x = $max_x = $marqueurs[0][0];
|
||||
$min_y = $max_y = $marqueurs[0][1];
|
||||
for ($i = 1; $i < count($marqueurs); ++$i) {
|
||||
$min_x = min($min_x, $marqueurs[$i][0]);
|
||||
$max_x = max($max_x, $marqueurs[$i][0]);
|
||||
$min_y = min($min_y, $marqueurs[$i][1]);
|
||||
$max_y = max($max_y, $marqueurs[$i][1]);
|
||||
$marks[$j] = array(
|
||||
'address' => $adresse,
|
||||
'title' => $titre,
|
||||
'text' => $texte,
|
||||
'type' => $type,
|
||||
'icon' => $icone
|
||||
);
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('marqueurs', $marqueurs);
|
||||
$this->view->assign('min_x', $min_x);
|
||||
$this->view->assign('max_x', $max_x);
|
||||
$this->view->assign('min_y', $min_y);
|
||||
$this->view->assign('max_y', $max_y);
|
||||
$this->view->assign('marks', json_encode($marks));
|
||||
}
|
||||
|
||||
protected function iconeDuMarqueur($naf, $siege, $actif)
|
||||
@ -1149,9 +1119,9 @@ class IdentiteController extends Zend_Controller_Action
|
||||
public function facadeAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
require_once 'Scores/Mappy.php';
|
||||
|
||||
|
||||
$infos = $request->getParam('infos');
|
||||
$source = $request->getParam('source');
|
||||
$mappy = new Mappy();
|
||||
@ -1190,19 +1160,19 @@ class IdentiteController extends Zend_Controller_Action
|
||||
public function streetviewAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
if ( $request->isXmlHttpRequest() ) {
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->layout()->disableLayout();
|
||||
}
|
||||
|
||||
|
||||
$lat = $request->getParam('lat', '');
|
||||
$lon = $request->getParam('lon', '');
|
||||
$num = $request->getParam('heading', 0);
|
||||
|
||||
|
||||
$streetview = new Scores_Streetview();
|
||||
if ( $lat != '' && $lon != '' ) {
|
||||
if ( $lat != '' && $lon != '' ) {
|
||||
$deg = $streetview->getNumDeg();
|
||||
$nbImg = count($deg);
|
||||
$nbImg = count($deg);
|
||||
$pagePrec = $num-1;
|
||||
if ($pagePrec<=0) {
|
||||
$pagePrec = $nbImg-1;
|
||||
@ -1210,7 +1180,7 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$pageSuiv = $num+1;
|
||||
if($pageSuiv>=$nbImg) {
|
||||
$pageSuiv = 0;
|
||||
}
|
||||
}
|
||||
$this->view->assign('pagePrec', $pagePrec);
|
||||
$this->view->assign('pageSuiv', $pageSuiv);
|
||||
$streetview->setLocationGeo( $lat, $lon );
|
||||
@ -1218,11 +1188,11 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$streetview->setHeading($heading);
|
||||
//$streetview->setLocationTxt($adresse);
|
||||
$this->view->assign('url', $streetview->urlImg());
|
||||
}
|
||||
}
|
||||
$this->view->assign('lat', $lat);
|
||||
$this->view->assign('lon', $lon);
|
||||
}
|
||||
|
||||
|
||||
public function groupesarboAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
@ -1,38 +1,64 @@
|
||||
<div id="carte" style="width:500px;height:500px"></div>
|
||||
<div id="carte" style="width:100%;height:500px"></div>
|
||||
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script type="text/javascript">
|
||||
<?php echo 'var marks = '.$this->marks.';'?>
|
||||
$(document).ready(function(){
|
||||
var myOptions = {
|
||||
zoom: 16,
|
||||
center: new google.maps.LatLng(<?=$this->marqueurs[0][0]?>,
|
||||
<?=$this->marqueurs[0][1]?>),
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
}
|
||||
var map = new google.maps.Map(document.getElementById('carte'), myOptions);
|
||||
var min_lat = 51.0889618;
|
||||
var max_lat = 41.3423276;
|
||||
var min_lng = 9.560067799999999;
|
||||
var max_lng = -5.141227900000001;
|
||||
|
||||
<?php for ($i = 0; $i < count($this->marqueurs); ++$i) { ?>
|
||||
var marker = new google.maps.Marker({
|
||||
map: map,
|
||||
position: new google.maps.LatLng(<?=$this->marqueurs[$i][0]?>,
|
||||
<?=$this->marqueurs[$i][1]?>),
|
||||
title: "<?=$this->marqueurs[$i][4]?>",
|
||||
icon: "<?=$this->marqueurs[$i][5]?>"
|
||||
});
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
var infowindow = new google.maps.InfoWindow({
|
||||
content: "<?=$this->marqueurs[$i][3]?>"
|
||||
//Create the map
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
var initCenter = new google.maps.LatLng(46.227638,2.213749);
|
||||
var mapOptions = {
|
||||
zoom: 8,
|
||||
center: initCenter,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var map = new google.maps.Map(document.getElementById('carte'), mapOptions);
|
||||
|
||||
var length = marks.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
codeAddress(marks, i);
|
||||
}
|
||||
|
||||
/*map.fitBounds(new google.maps.LatLngBounds(
|
||||
new google.maps.LatLng(min_lat, min_lng),
|
||||
new google.maps.LatLng(max_lat, max_lng))
|
||||
);*/
|
||||
|
||||
//Bounds the maps
|
||||
function codeAddress(marks, position) {
|
||||
geocoder.geocode( {'address': marks[position]['address'], region:'FR'}, function(results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
|
||||
var location = results[0].geometry.location;
|
||||
|
||||
if(position==0) {
|
||||
map.setCenter(location);
|
||||
}
|
||||
|
||||
//Create marker
|
||||
var marker = new google.maps.Marker({
|
||||
map: map,
|
||||
position: location,
|
||||
title: marks[position]['title'],
|
||||
icon: marks[position]['icon'],
|
||||
});
|
||||
|
||||
//Create event marker
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
var infowindow = new google.maps.InfoWindow({
|
||||
content: marks[position]['text']
|
||||
});
|
||||
var pos = new google.maps.Marker({
|
||||
position: location
|
||||
});
|
||||
infowindow.open(map, pos);
|
||||
});
|
||||
}
|
||||
});
|
||||
var pos = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(<?=$this->marqueurs[$i][0]?>,
|
||||
<?=$this->marqueurs[$i][1]?>)
|
||||
});
|
||||
infowindow.open(map, pos);
|
||||
});
|
||||
<?php } ?>
|
||||
<?php if (count($this->marqueurs) > 1) { ?>
|
||||
map.fitBounds(new google.maps.LatLngBounds(
|
||||
new google.maps.LatLng(<?=$this->min_x?>, <?=$this->min_y?>),
|
||||
new google.maps.LatLng(<?=$this->max_x?>, <?=$this->max_y?>)));
|
||||
<?php } ?>
|
||||
}
|
||||
});
|
||||
</script>
|
@ -16,9 +16,7 @@
|
||||
<td width="200" class="StyleInfoLib">Raison Sociale</td>
|
||||
<td width="350" class="StyleInfoData"><?=$this->raisonSociale?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($this->actif == -1 && is_array($this->etabs) && count($this->etabs)>0){
|
||||
?>
|
||||
<?php if ($this->actif == -1 && is_array($this->etabs) && count($this->etabs)>0){ ?>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td colspan="2" class="StyleInfoData">
|
||||
@ -51,7 +49,7 @@ if ($this->actif == -1 && is_array($this->etabs) && count($this->etabs)>0){
|
||||
|
||||
<h2>Établissements</h2>
|
||||
<div class="paragraph">
|
||||
<table>
|
||||
<table style="width:100%;">
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td colspan="2" width="550" class="StyleInfoData">
|
||||
@ -65,9 +63,9 @@ if ($this->actif == -1 && is_array($this->etabs) && count($this->etabs)>0){
|
||||
else $type = 'établ. ';
|
||||
if ($etab->Actif==1) $type.= 'actif';
|
||||
else $type.= 'inactif';
|
||||
|
||||
|
||||
if(intval($etab->Nic)==0 || intval($etab->Nic)>=99990) $type.=' provisoire';
|
||||
|
||||
|
||||
$href = $this->url(array(
|
||||
'controller' => 'identite',
|
||||
'action' => 'fiche',
|
||||
|
Loading…
Reference in New Issue
Block a user