-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapGoogleDB.php
69 lines (55 loc) · 2.18 KB
/
mapGoogleDB.php
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
<?php
include ('func/db.php');
$conexion = db_connect();
if (!$conexion)
return 0;
$rs = mysql_query("SELECT * FROM coordenadas WHERE id='1'");
while ($result = mysql_fetch_array($rs)) {
$id = $result['id'];
$coordenada1 = $result['coordenada1'];
$coordenada2 = $result['coordenada2'];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mapa</title>
<script src="http://maps.google.com/maps?file=api&v=3&key=ABQIAAAAp9wVclPicp2HGB4QNX-LLRTqx4D3bS478d-1w1nVZmw5mBzr_hTd8Hb4lXsLPv7hW7mRH6_tkUmJ3g" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function load() {
var coordenada1 = "<?php echo $coordenada1; ?>";
var coordenada2 = "<?php echo $coordenada2; ?>";
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(coordenada1, coordenada2), 15);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
}
function showAddress(address, zoom) {
if (geocoder) {
geocoder.getLatLng(address,
function (point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, zoom);
var marker = new GMarker(point);
map.addOverlay(marker);
document.form_mapa.coordenadas1.value = point.y;
document.form_mapa.coordenadas2.value = point.x;
}
}
);
}
}
</script>
</head>
<body onLoad="load();" onunload="GUnload();">
<center>
<div align="center" id="map" style="height: 425px; width: 425px;">
</div>
</center>
</body>
</html>