我想從PostgreSQL數(shù)據(jù)庫(kù)中提取經(jīng)度和緯度坐標(biāo),并在傳單地圖上顯示這些坐標(biāo)。使用下面的代碼,我能夠查詢數(shù)據(jù)庫(kù)中的數(shù)據(jù)并在瀏覽器上打印數(shù)據(jù)。索引.php<!DOCTYPE html><html><head><meta charset=utf-8"> <title>Map</title></head><body onload="init()"><h1>Map</h1><div><?php$conn = pg_connect("host=localhost port=5432 dbname=visualization user=postgres password=*******");$result = pg_query($conn,"SELECT lon,lat FROM pms_tunnel WHERE lon is not NULL or lat is not NULL");echo "<table>";while($row=pg_fetch_assoc($result)){ echo "<tr>"; echo "<td width='200'>" . $row['lon'] . "</td>"; echo "<td width='200'>" . $row['lat'] . "</td>"; echo "</tr>";}echo "</table>";pg_close($conn);?></div></body></html>使用下面的代碼,我能夠使用傳單顯示世界地圖,并在1經(jīng)緯度坐標(biāo)上繪制標(biāo)記。遵循 https://leafletjs.com/examples/quick-start/ 教程//Map Leafletvar mymap = L.map('mapid').setView([37.541999, 126.752747], 17);L.tileLayer('http://xdworld.vworld.kr:8080/2d/Base/201802/{z}/{x}/{y}.png',{ maxZoom: 20, subdomains:['mt0','mt1','mt2','mt3']}).addTo(mymap);var marker = L.marker([37.541999, 126.752747]).addTo(mymap); // 1 longitude latitude coord現(xiàn)在,我不想從經(jīng)度和緯度坐標(biāo)中放置1個(gè)標(biāo)記,而是在地圖上顯示數(shù)據(jù)庫(kù)中的所有坐標(biāo),并在每個(gè)坐標(biāo)上放置標(biāo)記。如何做到這一點(diǎn)?
如何通過(guò)從數(shù)據(jù)庫(kù)中提取所有坐標(biāo)來(lái)使用傳單在地圖上放置標(biāo)記?
飲歌長(zhǎng)嘯
2022-09-12 10:08:23