-1
(我自己學習,我知道我的代碼是凌亂的,inb4對不起) 我有一個表與一些數據和一個按鈕,我想,當我按下按鈕標記出現在地圖上的位置(SQL工作正常) 詢問你想要的任何信息!在此先感謝谷歌地圖API與HTML按鈕上的地方標記
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<!-- google maps api -->
<div id="map" style="width:600px;height:500px"></div>
<script>
function myMap() {
var santiago = new google.maps.LatLng(-33.4545832, -70.6541925);
var mapCanvas = document.getElementById("map");
var mapOptions = {center: santiago, zoom: 11};
var map = new google.maps.Map(mapCanvas, mapOptions);
function addmarker(lat, lon) {
var location = new google.maps.LatLng(lat, lon);
var marker = new google.maps.Marker({
position: location,
map: map
});
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDL5dMHBCV7crlostybmkuGBAXjOP3yawQ&callback=myMap">
</script>
<div id="tabla">
<table Style="width:35%">
<thead>
<tr>
<th>Tiempo prom</th>
<th>Origen</th>
<th>Señal Or</th>
<th>Destino</th>
<th>Mapa</th>
</tr>
</thead>
<tbody>
<?php
include "conexion.php";
include "func.php";
$sql = "SELECT avg(call_setup_time) as promllamada, CELL_ID_1, CELL_ID_2, avg(SENAL_1) as promsenal, LATITUD_1 as lat, LONGITUD_1 as lon from call_setup where SENAL_1<=-80 GROUP BY CELL_ID_1 ORDER BY promllamada desc limit 20";
$resultado = $conn->query($sql);
while ($row = $resultado->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['promllamada'] ?></td>
<td><?php echo $row['CELL_ID_1'] ?></td>
<td><?php echo $row['promsenal'] ?></td>
<td><?php echo $row['CELL_ID_2'] ?></td>
<td><button type="button" id="agregar" onclick="addmarker(<?php echo $row['lat'] . ", " . $row['lon']; ?>)">Ver en mapa</button></td>
<?php
}
?>
</tbody>
</table>
<!-- datos -->
</div>
<div id="datos"></div>
</body>
是的,這就是我一直在尋找!謝謝:) 還有一件事,是否有可能每次都不重新加載地圖? (希望你明白這個問題) –
不客氣。 「不重裝」是什麼意思? – doutriforce
我在表格的每一行有一個按鈕,每次我點擊一個按鈕,地圖重新加載到一個新的中心,是否可以讓地圖不做這個「眨眼」 –