Accueil/class/Gmap.php

62 lines
2.1 KiB
PHP
Raw Normal View History

2010-09-24 12:08:02 +02:00
<?php
class gmap extends Module {
//TODO rajouter les params en détail
protected static $paramsList = array(
'visibility'
);
public $params = array();
public function __construct($params){
$this->setParams($params);
echo '<script type="text/javascript" src="js/gmap.js"></script>
<link type="text/css" rel="stylesheet" href="css/gmap.css" />
<div id="myAdress"><label for="myAdressField"><img src="images/interface/map.png" /> Adresse pour Google Maps :</label><input type="text" name="myAdressField" id="myAdressField" /></div><a href="#map" id="gmapLink"></a><div id="map">';
include 'GoogleMapAPIv3.class.php';
$gmap = new GoogleMapAPI();
$gmap->setDivId('mymap'); //crée une div avec l'id donnée
//$gmap->setDirectionDivId('route');
$gmap->setCenter('Paris France'); // Adresse du centre par défaut
$gmap->setEnableWindowZoom(true); // Permet de zoomer (trop important !)
$gmap->setEnableAutomaticCenterZoom(false); // FALSE ! ou sinon le setCenter ne sert à rien !
//$gmap->setDisplayDirectionFields(false);
$gmap->setSize('400px','400px'); // La taille... duh !
$gmap->setZoom(11); // Le zoom (+ il est haut, plus le zoom est proche)
$gmap->setLang('fr'); // La langue par défaut
$gmap->setDefaultHideMarker(false); // Cache les markers ?
$gmap->generate(); // Génère le JS
echo $gmap->getGoogleMap();
echo '</div>';
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$gmap = new gmap($params);
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='gmap']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}