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
|
<?
require('GoogleMapAPI.class.php');
$map = new GoogleMapAPI('map');
$map->setAPIKey('xxx');
$map->setWidth("800px");
$map->setHeight("500px");
$map->setCenterCoords ('2', '48');
$map->setZoomLevel (5);
?>
<?php
mysql_connect("test", "test", "test");
mysql_select_db("test");
$cp = $_GET['cp'];
if($cp == '') { $cp = '75001'; }
$distance= '0';
$sql1="SELECT * FROM ville WHERE cp = '$cp'";
$req1 = mysql_query($sql1) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
while($data1 = mysql_fetch_assoc($req1))
{
$latitude = $data1['LAT'];
$longitude = $data1['LONG'];
}
$formule="(6366*acos(cos(radians($latitude))*cos(radians(`lat`))*cos(radians(`long`) -radians($longitude))+sin(radians($latitude))*sin(radians(`lat`))))";
$sql="SELECT *,$formule AS dist FROM ville WHERE $formule<='10' ORDER by dist ASC";
$req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req))
{
$ville = $data['maj'];
$latitude = $data['LAT'];
$longitude = $data['LONG'];
$sql2="SELECT * FROM buraliste WHERE cp='$ville'";
$req2 = mysql_query($sql2) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
while($data2 = mysql_fetch_assoc($req2))
{
$codepostal = $data2['cp'];
$enseigne = $data2['enseigne'];
$adresse = $data2['adresse'];
$map->addMarkerByCoords( $longitude, $latitude, "$enseigne $adresse $codepostal");
?>
<!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" xml:lang="fr" >
<head>
<title>Points de vente</title>
<?php $map->printHeaderJS(); ?>
<?php $map->printMapJS(); ?>
</head>
<body onload="onLoad();">
<? echo "$enseigne $adresse $codepostal"; ?><br>
<?
}
}
?><br><br>
<?php $map->printMap(); ?>
</body>
</html> |
Partager