以下是google给出的getQueryPredictions示例
service.getQueryPredictions({input: 'pizza near'}, callback);
Run Code Online (Sandbox Code Playgroud)
有没有办法限制特定国家/城市/州的结果?
其他功能/组件具有执行此操作的能力
var input = document.getElementById('searchTextField');
var options = { types: ['(cities)'], componentRestrictions: {country: 'fr'}};
autocomplete = new google.maps.places.Autocomplete(input, options);
Run Code Online (Sandbox Code Playgroud) https://google-developers.appspot.com/maps/documentation/javascript/examples/places-autocomplete
我有一个类似于上面的谷歌地方自动完成演示网址,如果我键入白金汉宫.它将返回结果
等等.我如何从结果中删除英国伦敦?
请看下面的代码
function GetAreaName($AreaCode)
{
switch ($AreaCode)
{
case 201: return 'New Jersey';
case 202: return 'Washington';
// this goes on till
case 999: return '';
}
}
Run Code Online (Sandbox Code Playgroud)
假设AreaCode是998,那么就必须经历这么多案件!我们怎样才能优化这个功能?(不使用数据库.)
我正在考虑构建一个数组并对其进行二进制搜索?但是这意味着每次调用该函数时都会重建数组?我们如何构建一次数组,缓存它并在每次调用此函数时重复使用?
https://google-developers.appspot.com/maps/documentation/javascript/examples/places-autocomplete
我有一个类似的页面与上面的谷歌地方演示.请注意,位置输入字段有一个"输入位置"的提示.我如何更改此提示的语言?我如何更改结果返回的语言?我想他们两个都是相同的设置?
通过以下示例,
https://google-developers.appspot.com/maps/documentation/javascript/examples/place-search
我可以获得附近的商店列表到pyrmont,但我也想知道商店距离pyrmont的距离以及汽车和步行的大致旅行时间.我怎么能得到这些信息?