使用谷歌地图,我希望能够检索并显示给定点固定半径内的所有位置。
我已经找到了显示位置指南,也看到了许多关于使用SQL查询检索它的帖子。我的数据库包含物品名称、地址(查找alt、lon)、alt、lon和描述。
如何使用存储的alt、lon仅检索50公里半径内的位置。
以下是我的代码:
javascript
我认为我需要在循环中使用
我尝试使用Display Location指南中的DisplayLocations()方法,但它对我不起作用,尽管那里呈现位置的方式非常完美,只需要排除超出半径范围的位置。
我已经找到了显示位置指南,也看到了许多关于使用SQL查询检索它的帖子。我的数据库包含物品名称、地址(查找alt、lon)、alt、lon和描述。
如何使用存储的alt、lon仅检索50公里半径内的位置。
以下是我的代码:
javascript
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(31.046051, 34.85161199999993);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function updateCoordinates(latlng)
{
if(latlng)
{
document.getElementById('lat').value = latlng.lat();
document.getElementById('lng').value = latlng.lng();
}
}
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
updateCoordinates(results[0].geometry.location);
if (marker) marker.setMap(null);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
draggable: true
});
google.maps.event.addListener(marker, "dragend", function() {
updateCoordinates(marker.getPosition());
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
function showPositionCoupons(sentlat, sentlon)
{
lat=sentlat;
lon=sentlon;
latlon=new google.maps.LatLng(lat, lon)
mapholder=document.getElementById('map_canvas')
var myOptions={
center:latlon,zoom:14,
mapTypeId:google.maps.MapTypeId.ROADMAP,
mapTypeControl:false,
};
map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
marker = new google.maps.Marker({position:latlon,map:map,title:"You are here!"});
}
我认为我需要在循环中使用
showPositionCoupons()
,同时读取alt和lon。感谢提供任何帮助,我知道这是一个频繁的问题,但我无法使用现有内容解决它。我尝试使用Display Location指南中的DisplayLocations()方法,但它对我不起作用,尽管那里呈现位置的方式非常完美,只需要排除超出半径范围的位置。