是否有可能通过谷歌地方api或其他东西获得给定国家的所有机场。
提前致谢。
答案 0 :(得分:2)
答案 1 :(得分:0)
您需要使用Google搜索控件和地图
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=yourkey=false"></script>
<script type="text/javascript">
google.load('search', '1');
</script>
<script type="text/javascript">
var map;
var searcher;
function OnLoad() {
var defaultLoc = new google.maps.LatLng(7.885, 80.651);
var defaultMapOp = {
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: defaultLoc,
noClear: false
};
map = new google.maps.Map(document.getElementById('mapDiv'), defaultMapOp);
var searchControl = new google.search.SearchControl();
searcher = new google.search.LocalSearch();
searcher.setCenterPoint(map);
var options = new google.search.SearcherOptions();
options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
/*var opAutoComplete = new google.search.DrawOptions();
opAutoComplete.setAutoComplete(true);*/
searchControl.addSearcher(searcher, options);
//searchControl.draw(searcher, opAutoComplete);
searchControl.setSearchCompleteCallback(searcher, function () {
var results = searcher.results;
for (var i = 0; i < results.length; i++) {
var result = results[i];
var markerLatLng = new google.maps.LatLng(parseFloat(result.lat), parseFloat(result.lng));
var marker = new google.maps.Marker({
map: map,
position: markerLatLng,
title: result.titleNoFormatting
});
}
var center = searcher.resultViewport.center;
map.setCenter(new google.maps.LatLng(parseFloat(center.lat), parseFloat(center.lng)));
});
searchControl.draw(document.getElementById('searchDiv'));
}
google.setOnLoadCallback(OnLoad);
</script>