選擇記錄我已經經度和緯度存儲在數據庫中像與最接近的經度和緯度
表名:km_stores 領域:STORE_ID,store_long,store_lat,STORE_NAME
我如何使用他們拉最近的商店經度和緯度?
我使用的,因爲我正在使用的WordPress插件頁面PHP
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
document.getElementById("km_long").value = position.coords.latitude;
document.getElementById("km_lat").value = position.coords.longitude;
}
</script>
<strong>Long:</strong> <input type="text" id="km_long" /> <strong>Latitude:</strong> <input type="text" id="km_lat" />
[php]
global $wpdb;
$results = $wpdb->get_results('select * from km_stores', OBJECT);
foreach ($results as $store) {
echo $store->store_name;
}
[/php]
[php][/php]
標籤。
可能的重複:http://stackoverflow.com/questions/5031268/algorithm-to-find-all-latitude-longitude-locations-within-a-certain-distance-fro – hindmost