我在使用地理编码器和融合表时搜索位置半径函数有困难,其中列X和Y存储长lat。实际上问题出在查询的WHERE条件中。谢谢你,如果你可以调试。这是我的功能:
function CP_query() {
CPsearch = document.getElementById('CP_Input').value;
geocoder.geocode( { 'address': CPsearch}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
mylat = results[0].geometry.location.lat();
mylon = results[0].geometry.location.lng();
//alert("lat : " + mylat + "long: " + mylon);
layer_imm = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: '1ckqpE8ZxVzfgJ5bT-vAkpBwjVANbV-KiNjfScjw',
where: '6371 * acos( cos( radians(' + mylat + ') ) * cos( radians( Y ) ) * cos( radians( X ) - radians(' + mylon + ') ) + sin( radians(' + mylat + ') ) * sin( radians( Y ) ) ) < 2'
}
});
layer_imm.setMap(map);
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
答案 0 :(得分:1)
3218米是圆的半径。
query: {
select:'geometry'
from: '1ckqpE8ZxVzfgJ5bT-vAkpBwjVANbV-KiNjfScjw',
where: 'ST_INTERSECTS(geometry,CIRCLE(LATLNG('+ mylat + ',' + mylon + '), 3218))'
}