-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_map2.php
117 lines (108 loc) · 2.88 KB
/
show_map2.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<style>
#map {
height: 400px;
width: 100%;
}
</style>
<?php
$host = "host=127.0.0.1";
$port = "port=5432";
$dbname = "dbname=ko";
$credentials = "user=postgres password=peet";
$db = pg_connect("$host $port $dbname $credentials") ;
if(!$db) {
echo "Error : Unable to open database\n";
} else {
echo "Opened database successfully\n";
}
$sql = <<<EOF
(SELECT *FROM kk where field_5 BETWEEN 90 AND 100 );
EOF;
$ret = pg_query($db, $sql) ;
if(!$ret) {
echo pg_last_error($db) ;
exit;
}
$sql = <<<EOF
(SELECT *FROM kk where field_5 BETWEEN 80 AND 89 );
EOF;
$res = pg_query($db, $sql) ;
if(!$res) {
echo pg_last_error($db) ;
exit;
}
?>
</head>
<body>
<h3>My Google Maps</h3>
<div id="map"></div>
<script>
// The following example creates a marker in Stockholm, Sweden using a DROP
// animation. Clicking on the marker will toggle the animation between a BOUNCE
// animation and no animation.
var marker;
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: {lat: 35.84486, lng: 128.594692}
});
<?php
$num_row = pg_num_rows($ret);
$k = 0;
while($row = pg_fetch_row($ret) ){
?>
marker = new google.maps.Marker({
map: map,
draggable: false,
icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
//http://maps.google.com/mapfiles/ms/icons/blue-dot.png or http://maps.google.com/mapfiles/ms/icons/red-dot.png
animation: google.maps.Animation.BOUNCE,
position: {lat:<?php echo $row["7"];?>, lng:<?php echo $row["8"];?>},
});
<?php
$k++;
if($k > 100) {break;}
}
?>
}
</script>
<div id="map"></div>
<script>
var marker1;
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: {lat: 35.84486, lng: 128.594692}
});
<?php
$num_row = pg_num_rows($res);
$k = 0;
while($row = pg_fetch_row($res) ){
?>
marker1 = new google.maps.Marker({
map: map,
draggable: false,
icon: 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
//http://maps.google.com/mapfiles/ms/icons/blue-dot.png or http://maps.google.com/mapfiles/ms/icons/red-dot.png
animation: google.maps.Animation.BOUNCE,
position: {lat:<?php echo $row["7"];?>, lng:<?php echo $row["8"];?>},
});
<?php
$k++;
if($k > 100) {break;}
}
?>
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBeVERtl6-MScPy5xT3ysrJsM4zRkcjGaY&callback=initMap">
</script>
<?php
pg_close($db) ;
?>
</body>
</html>