select st_distance 因为 'distance' 在 google 融合中不起作用 table
select st_distance as 'distance' not working in google fusion table
ST_DISTANCE AS 'distance' 无法处理以下代码:
var query = "SELECT 'Coordinates' as 'Coordinates', " +
"'Lender_Name' as 'Lender_Name', " +
"'ZIP_Code' as 'ZIP_Code' , " +
"ST_DISTANCE('Coordinates', 'LATLNG(" + lat + " " + long + ")') AS 'distance' " +
" FROM " + tableid + " ORDER BY ST_DISTANCE(Coordinates, LATLNG(" + lat + "," + long + ")) LIMIT 5";
当我在没有 ST_DISTANCE 作为距离的情况下使用时,它对我来说工作正常:
var query = "SELECT 'Coordinates' as 'Coordinates', " +
"'Lender_Name' as 'Lender_Name', " +
"'ZIP_Code' as 'ZIP_Code' " +
" FROM " + tableid + " ORDER BY ST_DISTANCE(Coordinates, LATLNG(" + lat + "," + long + ")) LIMIT 5";
任何人都可以帮助我如何获得 st_distance 的别名?
我已经通过下面的代码实现了解决
function initialize() {
//CONVERT THE MAP DIV TO A FULLY-FUNCTIONAL GOOGLE MAP
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var output = '<tr><th scope="col">From</th><th scope="col">To</th><th scope="col">Miles</th></tr>';
var currZipCode = 99929;
currZipCode = currZipCode.toString();
var destinationZipCode = 99803;
destinationZipCode = destinationZipCode.toString();
calcMileage();
function calcMileage() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [ currZipCode ],
destinations: [ destinationZipCode ],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL
}, function(response, status) {
if(status == google.maps.DistanceMatrixStatus.OK) {
var tempDistance = response.rows[0].elements[0].distance.text;
} else {
var tempDistance = 'ERROR';
}
//STORE CURRENT OUTPUT AND GET THE NEXT DESTINATION
output += '<tr><td>' + currZipCode + '</td><td>' + destinationZipCode + '</td><td>' + tempDistance + '</td></tr>';
displayResults();
}
);
function displayResults() {
document.getElementById('zip_code_output').innerHTML = '<table cellpadding="5">' + output + '</table>';
}
}
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
}
//START THE SCRIPT (AFTER THE PAGE LOADS)
window.onload = loadScript;
ST_DISTANCE AS 'distance' 无法处理以下代码:
var query = "SELECT 'Coordinates' as 'Coordinates', " +
"'Lender_Name' as 'Lender_Name', " +
"'ZIP_Code' as 'ZIP_Code' , " +
"ST_DISTANCE('Coordinates', 'LATLNG(" + lat + " " + long + ")') AS 'distance' " +
" FROM " + tableid + " ORDER BY ST_DISTANCE(Coordinates, LATLNG(" + lat + "," + long + ")) LIMIT 5";
当我在没有 ST_DISTANCE 作为距离的情况下使用时,它对我来说工作正常:
var query = "SELECT 'Coordinates' as 'Coordinates', " +
"'Lender_Name' as 'Lender_Name', " +
"'ZIP_Code' as 'ZIP_Code' " +
" FROM " + tableid + " ORDER BY ST_DISTANCE(Coordinates, LATLNG(" + lat + "," + long + ")) LIMIT 5";
任何人都可以帮助我如何获得 st_distance 的别名?
我已经通过下面的代码实现了解决
function initialize() {
//CONVERT THE MAP DIV TO A FULLY-FUNCTIONAL GOOGLE MAP
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var output = '<tr><th scope="col">From</th><th scope="col">To</th><th scope="col">Miles</th></tr>';
var currZipCode = 99929;
currZipCode = currZipCode.toString();
var destinationZipCode = 99803;
destinationZipCode = destinationZipCode.toString();
calcMileage();
function calcMileage() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [ currZipCode ],
destinations: [ destinationZipCode ],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL
}, function(response, status) {
if(status == google.maps.DistanceMatrixStatus.OK) {
var tempDistance = response.rows[0].elements[0].distance.text;
} else {
var tempDistance = 'ERROR';
}
//STORE CURRENT OUTPUT AND GET THE NEXT DESTINATION
output += '<tr><td>' + currZipCode + '</td><td>' + destinationZipCode + '</td><td>' + tempDistance + '</td></tr>';
displayResults();
}
);
function displayResults() {
document.getElementById('zip_code_output').innerHTML = '<table cellpadding="5">' + output + '</table>';
}
}
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
}
//START THE SCRIPT (AFTER THE PAGE LOADS)
window.onload = loadScript;