<?php
/**
* MiniClick
* Gestionnaire de tableau collaboratif
* Copyright (C) 2006 Guillaume Monet <gm@ibreizh.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
*
* @package miniclick
* @version 5.0.0
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Localisation GPS</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAijLYGZEd0DGlk-UXAvsPMhT4o0Q0XAMFrZoBLdmIUMeW4DUPIRRRolYTTiibLHxW6cSDpI-0qp1AZA"
      type="text/javascript"></script>

    <script type="text/javascript">
    	var geocoder = new GClientGeocoder();
	function load(){
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			<?php
			$risques = mysql_query($this->no_limit_query);
			while($risq=mysql_fetch_object($risques)){
				$loc = $risq->Adresse." ".$risq->cp.", ".$risq->Ville_Id.", France";?>
				geocoder.getLatLng('<?php echo $loc;?>',
					function(point) {
						if (!point) {
							//alert('<?php echo $loc;?> Non trouver');	
						}else{
							map.setCenter(point, 13);
							var marker = createMarker(point,'<?php echo $loc;?>');
							map.addOverlay(marker);
						}
					}
				);<?php			
			}
			
		?>
	}


	function createMarker(point, number) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
    			marker.openInfoWindowHtml("<b>" + number + "</b>");
  		});
  		return marker;
	}

        </script>
  </head>
  <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 800px; height: 600px"></div>
  </body>
</html>
