';
+
+ 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 '
';
+ }
+
+ 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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/class/GoogleMapAPIv3.class.php b/class/GoogleMapAPIv3.class.php
new file mode 100644
index 0000000..a4c889c
--- /dev/null
+++ b/class/GoogleMapAPIv3.class.php
@@ -0,0 +1,727 @@
+
+* @copyright (c) 2010 CERDAN Yohann, All rights reserved
+* @ version 12/08/2010
+*/
+
+if(isset($_GET['source'])) {
+ highlight_file(__FILE__);
+ die;
+}
+
+class GoogleMapAPI
+{
+ /** GoogleMap ID for the HTML DIV **/
+ protected $googleMapId = 'googlemapapi';
+
+ /** GoogleMap Direction ID for the HTML DIV **/
+ protected $googleMapDirectionId = 'route';
+
+ /** Width of the gmap **/
+ protected $width = '';
+
+ /** Height of the gmap **/
+ protected $height = '';
+
+ /** Icon width of the gmarker **/
+ protected $iconWidth = 57;
+
+ /** Icon height of the gmarker **/
+ protected $iconHeight = 34;
+
+ /** Infowindow width of the gmarker **/
+ protected $infoWindowWidth = 250;
+
+ /** Default zoom of the gmap **/
+ protected $zoom = 9;
+
+ /** Enable the zoom of the Infowindow **/
+ protected $enableWindowZoom = false;
+
+ /** Default zoom of the Infowindow **/
+ protected $infoWindowZoom = 3;
+
+ /** Lang of the gmap **/
+ protected $lang = 'fr';
+
+ /**Center of the gmap **/
+ protected $center = 'Paris France';
+
+ /** Content of the HTML generated **/
+ protected $content = '';
+
+ /** Add the direction button to the infowindow **/
+ protected $displayDirectionFields = false;
+
+ /** Hide the marker by default **/
+ protected $defaultHideMarker = false;
+
+ /** Extra content (marker, etc...) **/
+ protected $contentMarker = '';
+
+ /** Use clusterer to display a lot of markers on the gmap **/
+ protected $useClusterer = false;
+ protected $gridSize = 100;
+ protected $maxZoom = 9;
+ protected $clustererLibrarypath = 'http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js';
+
+ /** Enable automatic center/zoom **/
+ protected $enableAutomaticCenterZoom = false;
+
+ /** maximum longitude of all markers **/
+ protected $maxLng = -1000000;
+
+ /** minimum longitude of all markers **/
+ protected $minLng = 1000000;
+
+ /** max latitude of all markers **/
+ protected $maxLat = -1000000;
+
+ /** min latitude of all markers **/
+ protected $minLat = 1000000;
+
+ /** map center latitude (horizontal), calculated automatically as markers are added to the map **/
+ protected $centerLat = null;
+
+ /** map center longitude (vertical), calculated automatically as markers are added to the map **/
+ protected $centerLng = null;
+
+ /** factor by which to fudge the boundaries so that when we zoom encompass, the markers aren't too close to the edge **/
+ protected $coordCoef = 0.01;
+
+
+
+ /**
+ * Class constructor
+ *
+ * @return void
+ */
+
+ public function __construct()
+ {
+ }
+
+ /**
+ * Set the useClusterer parameter (optimization to display a lot of marker)
+ *
+ * @param boolean $useClusterer use cluster or not
+ * @param int $gridSize grid size (The grid size of a cluster in pixel. Each cluster will be a square. If you want the algorithm to run faster, you can set this value larger. The default value is 100.)
+ * @param int $maxZoom maxZoom (The max zoom level monitored by a marker cluster. If not given, the marker cluster assumes the maximum map zoom level. When maxZoom is reached or exceeded all markers will be shown without cluster.)
+ * @param int $clustererLibraryPath clustererLibraryPath
+ *
+ * @return void
+ */
+
+ public function setClusterer($useClusterer,$gridSize=100,$maxZoom=9,$clustererLibraryPath='')
+ {
+ $this->useClusterer = $useClusterer;
+ $this->gridSize = $gridSize;
+ $this->maxZoom = $maxZoom;
+ ($clustererLibraryPath=='') ? $this->clustererLibraryPath = 'http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js' : $clustererLibraryPath;
+ }
+
+ /**
+ * Set the ID of the default gmap DIV
+ *
+ * @param string $googleMapId the google div ID
+ *
+ * @return void
+ */
+
+ public function setDivId($googleMapId)
+ {
+ $this->googleMapId = $googleMapId;
+ }
+
+ /**
+ * Set the ID of the default gmap direction DIV
+ *
+ * @param string $googleMapDirectionId GoogleMap Direction ID for the HTML DIV
+ *
+ * @return void
+ */
+
+ public function setDirectionDivId($googleMapDirectionId)
+ {
+ $this->googleMapDirectionId = $googleMapDirectionId;
+ }
+
+ /**
+ * Set the size of the gmap
+ *
+ * @param int $width GoogleMap width
+ * @param int $height GoogleMap height
+ *
+ * @return void
+ */
+
+ public function setSize($width,$height)
+ {
+ $this->width = $width;
+ $this->height = $height;
+ }
+
+ /**
+ * Set the with of the gmap infowindow (on marker clik)
+ *
+ * @param int $infoWindowWidth GoogleMap info window width
+ *
+ * @return void
+ */
+
+ public function setInfoWindowWidth ($infoWindowWidth)
+ {
+ $this->infoWindowWidth = $infoWindowWidth;
+ }
+
+ /**
+ * Set the size of the icon markers
+ *
+ * @param int $iconWidth GoogleMap marker icon width
+ * @param int $iconHeight GoogleMap marker icon height
+ *
+ * @return void
+ */
+
+ public function setIconSize($iconWidth,$iconHeight)
+ {
+ $this->iconWidth = $iconWidth;
+ $this->iconHeight = $iconHeight;
+ }
+
+ /**
+ * Set the lang of the gmap
+ *
+ * @param string $lang GoogleMap lang : fr,en,..
+ *
+ * @return void
+ */
+
+ public function setLang($lang)
+ {
+ $this->lang = $lang;
+ }
+
+ /**
+ * Set the zoom of the gmap
+ *
+ * @param int $zoom GoogleMap zoom.
+ *
+ * @return void
+ */
+
+ public function setZoom($zoom)
+ {
+ $this->zoom = $zoom;
+ }
+
+ /**
+ * Set the zoom of the infowindow
+ *
+ * @param int $zoom GoogleMap zoom.
+ *
+ * @return void
+ */
+
+ public function setInfoWindowZoom($infoWindowZoom)
+ {
+ $this->infoWindowZoom = $infoWindowZoom;
+ }
+
+ /**
+ * Enable the zoom on the marker when you click on it
+ *
+ * @param int $zoom GoogleMap zoom.
+ *
+ * @return void
+ */
+
+ public function setEnableWindowZoom($enableWindowZoom)
+ {
+ $this->enableWindowZoom = $enableWindowZoom;
+ }
+
+ /**
+ * Enable theautomatic center/zoom at the gmap load
+ *
+ * @param int $zoom GoogleMap zoom.
+ *
+ * @return void
+ */
+
+ public function setEnableAutomaticCenterZoom($enableAutomaticCenterZoom)
+ {
+ $this->enableAutomaticCenterZoom = $enableAutomaticCenterZoom;
+ }
+
+ /**
+ * Set the center of the gmap (an address)
+ *
+ * @param string $center GoogleMap center (an address)
+ *
+ * @return void
+ */
+
+ public function setCenter($center)
+ {
+ $this->center = $center;
+ }
+
+ /**
+ * Set the center of the gmap
+ *
+ * @param boolean $displayDirectionFields display directions or not in the info window
+ *
+ * @return void
+ */
+
+ public function setDisplayDirectionFields($displayDirectionFields)
+ {
+ $this->displayDirectionFields = $displayDirectionFields;
+ }
+
+ /**
+ * Set the defaultHideMarker
+ *
+ * @param boolean $defaultHideMarker hide all the markers on the map by default
+ *
+ * @return void
+ */
+
+ public function setDefaultHideMarker($defaultHideMarker)
+ {
+ $this->defaultHideMarker = $defaultHideMarker;
+ }
+
+ /**
+ * Get the google map content
+ *
+ * @return string the google map html code
+ */
+
+ public function getGoogleMap()
+ {
+ return $this->content;
+ }
+
+ /**
+ * Get URL content using cURL.
+ *
+ * @param string $url the url
+ *
+ * @return string the html code
+ *
+ * @todo add proxy settings
+ */
+
+ public function getContent($url)
+ {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_TIMEOUT, 10);
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($curl, CURLOPT_URL, $url);
+ $data = curl_exec($curl);
+ curl_close ($curl);
+ return $data;
+ }
+
+ /**
+ * Geocoding an address (address -> lat,lng)
+ *
+ * @param string $address an address
+ *
+ * @return array array with precision, lat & lng
+ */
+
+ public function geocoding($address)
+ {
+ $encodeAddress = urlencode($address);
+ $url = "http://maps.google.com/maps/geo?q=".$encodeAddress."&output=csv";
+
+ if(function_exists('curl_init')) {
+ $data = $this->getContent($url);
+ } else {
+ $data = file_get_contents($url);
+ }
+
+ $csvSplit = preg_split("/,/",$data);
+ $status = $csvSplit[0];
+
+ if (strcmp($status, "200") == 0) {
+ $return = $csvSplit; // successful geocode, $precision = $csvSplit[1],$lat = $csvSplit[2],$lng = $csvSplit[3];
+ } else {
+ $return = null; // failure to geocode
+ }
+
+ return $return;
+ }
+
+ /**
+ * Add marker by his coord
+ *
+ * @param string $lat lat
+ * @param string $lng lngs
+ * @param string $html html code display in the info window
+ * @param string $category marker category
+ * @param string $icon an icon url
+ *
+ * @return void
+ */
+
+ public function addMarkerByCoords($lat,$lng,$title,$html='',$category='',$icon='')
+ {
+ if ($icon=='') {
+ $icon = 'http://maps.gstatic.com/intl/fr_ALL/mapfiles/markers/marker_sprite.png';
+ }
+
+ // Save the lat/lon to enable the automatic center/zoom
+ $this->maxLng = (float) max((float)$lng, $this->maxLng);
+ $this->minLng = (float) min((float)$lng, $this->minLng);
+ $this->maxLat = (float) max((float)$lat, $this->maxLat);
+ $this->minLat = (float) min((float)$lat, $this->minLat);
+ $this->centerLng = (float) ($this->minLng + $this->maxLng) / 2;
+ $this->centerLat = (float) ($this->minLat + $this->maxLat) / 2;
+
+ $this->contentMarker .= "\t".'addMarker(new google.maps.LatLng("'.$lat.'","'.$lng.'"),"'.$title.'","'.$html.'","'.$category.'","'.$icon.'");'."\n";
+ }
+
+ /**
+ * Add marker by his address
+ *
+ * @param string $address an ddress
+ * @param string $content html code display in the info window
+ * @param string $category marker category
+ * @param string $icon an icon url
+ *
+ * @return void
+ */
+
+ public function addMarkerByAddress($address,$title='',$content='',$category='',$icon='')
+ {
+ $point = $this->geocoding($address);
+ if ($point!==null) {
+ $this->addMarkerByCoords($point[2], $point[3], $title, $content, $category, $icon);
+ } else {
+ // throw new Exception('Adress not found : '.$address);
+ }
+ }
+
+ /**
+ * Add marker by an array of coord
+ *
+ * @param string $coordtab an array of lat,lng,content
+ * @param string $category marker category
+ * @param string $icon an icon url
+ *
+ * @return void
+ */
+
+ public function addArrayMarkerByCoords($coordtab,$category='',$icon='')
+ {
+ foreach ($coordtab as $coord) {
+ $this->addMarkerByCoords($coord[0], $coord[1], $coord[2], $coord[3], $category, $icon);
+ }
+ }
+
+ /**
+ * Add marker by an array of address
+ *
+ * @param string $coordtab an array of address
+ * @param string $category marker category
+ * @param string $icon an icon url
+ *
+ * @return void
+ */
+
+ public function addArrayMarkerByAddress($coordtab,$category='',$icon='')
+ {
+ foreach ($coordtab as $coord) {
+ $this->addMarkerByAddress($coord[0], $coord[1], $coord[2], $category, $icon);
+ }
+ }
+
+ /**
+ * Set a direction between 2 addresss and set a text panel
+ *
+ * @param string $from an address
+ * @param string $to an address
+ *
+ * @return void
+ */
+
+ public function addDirection($from,$to)
+ {
+ $this->contentMarker .= 'addDirection("'.$from.'","'.$to.'");';
+ }
+
+ /**
+ * Parse a KML file and add markers to a category
+ *
+ * @param string $url url of the kml file compatible with gmap and gearth
+ * @param string $category marker category
+ * @param string $icon an icon url
+ *
+ * @return void
+ */
+
+ public function addKML ($url,$category='',$icon='')
+ {
+ $xml = new SimpleXMLElement($url, null, true);
+ foreach ($xml->Document->Folder->Placemark as $item) {
+ $coordinates = explode(',', (string) $item->Point->coordinates);
+ $name = (string) $item->name;
+ $this->addMarkerByCoords($coordinates[1], $coordinates[0], $name, $name, $category, $icon);
+ }
+ }
+
+ /**
+ * Initialize the javascript code
+ *
+ * @return void
+ */
+
+ public function init()
+ {
+ // Google map DIV
+ if (($this->width!='')&&($this->height!='')) {
+ $this->content .= "\t".''."\n";
+ } else {
+ $this->content .= "\t".''."\n";
+ }
+
+
+ // Google map JS
+ $this->content .= ''."\n";
+
+ // Clusterer JS
+ if ($this->useClusterer==true) {
+ $this->content .= ''."\n";
+ }
+
+ $this->content .= ''."\n";
+
+ }
+
+}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/css/gmap.css b/css/gmap.css
new file mode 100644
index 0000000..d1e0782
--- /dev/null
+++ b/css/gmap.css
@@ -0,0 +1,4 @@
+#myAdress{float:right; margin:12px 10px 0 0;}
+#route {height: 130px;overflow-y: auto;}
+#global {text-align: center;margin-left: auto; margin-right: auto;}
+#route {height: 130px;overflow-y: auto;}
diff --git a/db/config.xml b/db/config.xml
index 99d4d8c..9e913e3 100644
--- a/db/config.xml
+++ b/db/config.xml
@@ -55,4 +55,7 @@
true
+
+ true
+
diff --git a/images/interface/map.png b/images/interface/map.png
new file mode 100644
index 0000000..f90ef25
Binary files /dev/null and b/images/interface/map.png differ
diff --git a/js/gmap.js b/js/gmap.js
new file mode 100644
index 0000000..bd5deb5
--- /dev/null
+++ b/js/gmap.js
@@ -0,0 +1,23 @@
+
+$(document).ready(function(){
+
+ $('#menu-bar').append($('#myAdress'));
+ $('#map').css({'visibility':'hidden'});
+ $('#gmapLink').fancybox({
+ 'transitionIn': 'elastic',
+ 'transitionOut': 'elastic',
+ 'onClosed': function(){$('#map').css({'visibility':'hidden'});},
+ 'onStart': function(){$('#map').css({'visibility':'visible'});}
+ });
+ $('#myAdressField').keydown(function(e){
+ var code = (e.keyCode ? e.keyCode : e.which);
+ if(code == 13) {
+ var adress = $(this).val();
+ geocodeMarker(adress,adress,adress,'','http://maps.gstatic.com/intl/fr_ALL/mapfiles/markers/marker_sprite.png');
+ geocodeCenter(adress);
+ $('#gmapLink').trigger('click');
+
+ }
+ });
+});
+