1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| <?
require('GoogleMapAPI.class.php');
$sql = "SELECT * FROM $t_ads" ;
$Array_map = @mysql_query($sql) or die($sql.mysql_error());
$map = new GoogleMapAPI('map','tutoriel_map');
$map->setAPIKey('ABQIAAAA0wpaGCWxMNf1vpHWlO2BHBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQDZuHfuMbt-f3nE5QBK8kKOQbAWw');
$map->setHeight("650");
$map->setWidth("600");
$map->disableSidebar();
$map->disableTypeControls();
$map->setMapType('map'); // default
$map->disableDirections();
$map->enableZoomEncompass();
$map->disableOverviewControl();
while ($row = mysql_fetch_assoc($Array_map)){
$Adresse = $row['area'].", FRANCE";
$enabled = $row['enabled'];
if($enabled)
{
$map->addMarkerIcon('http://localhost/images/pin_green.gif');
}
else
{
$map->addMarkerIcon('http://localhost/images/pin_red.gif');
}
$map->addMarkerByAddress($Adresse);
//echo $Adresse ."<br>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Tutoriel Google Map API avec PHP</title>
<?php $map->printHeaderJS(); ?>
<?php $map->printMapJS(); ?>
<style type="text/css">
v\:* { behavior:url(#default#VML);}
/*pour les infobulles de la carte*/
#gmapmarker { font: normal small verdana, arial, helvetica, sans-serif; font-size: 10pt; margin: 0px; width: 350px; height: 150px; overflow:auto;}
#gmapmarker p{ margin : 0; padding : 2px 0 2px 0;}
#gmapmarker a {text-decoration: none; color: #0066CC; background-color: transparent;}
#gmapmarker a:hover {color: #F60; background-color: transparent;}
#gmapmarker h1 { font-weight: bold; font-size: 13px; color: #369; border-bottom: 2px solid #369; padding : 2px; margin : 0;}
.annonce li {list-style-type:none;}
.on li {color: blue;display : list-item;margin-left:15px;}
.off li {color: red;display : list-item;margin-left:15px;}
/*div qui contient la carte*/
#map { float : left;}
</style>
</head>
<body onload="onLoad()">
<table border=1>
<tr><td>
<?php $map->printMap(); //on affiche la map ?>
</td><td>
<?php $map->printSidebar(); //on affiche la barre de navigation ?>
</td></tr>
</table>
</body>
</html> |
Partager