Google maps 我只希望“印度”的所有城市都能通过Ngautomplete来展示。。???我必须在Ngautomplete中进行哪些更改。。?
我只想通过ngAutocomplete.js为印度所有城市提供选项…远低于ngAutocomplete.js的代码Google maps 我只希望“印度”的所有城市都能通过Ngautomplete来展示。。???我必须在Ngautomplete中进行哪些更改。。?,google-maps,Google Maps,我只想通过ngAutocomplete.js为印度所有城市提供选项…远低于ngAutocomplete.js的代码 var opts; var initOpts = function() { opts = {} if (scope.options) { if (scope.options.types) { opts.types = [] opts.types.push(scope.options.ty
var opts;
var initOpts = function() {
opts = {}
if (scope.options) {
if (scope.options.types) {
opts.types = []
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: 'IN'
}
}
}
}
对你来说幸运的是,谷歌JS文档中有很多内容。此功能使用componentRestrictions选项将自动完成搜索限制到特定国家/地区。以下是给您的一个片段:
var opts;
var initOpts = function() {
opts = {}
if (scope.options) {
if (scope.options.types) {
opts.types = []
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: 'IN'
}
}
}
}
var input = document.getElementById('searchTextField');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'in'}
};
autocomplete = new google.maps.places.Autocomplete(input, options);
下面是一个来自谷歌地图的示例
var opts;
var initOpts = function() {
opts = {}
if (scope.options) {
if (scope.options.types) {
opts.types = []
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: 'IN'
}
}
}
}
$scope.getOnlyINDIA = {
country: 'in',
types: '(cities)'
};
将此添加到控制器,然后在自动完成文本框中添加
var opts;
var initOpts = function() {
opts = {}
if (scope.options) {
if (scope.options.types) {
opts.types = []
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: 'IN'
}
}
}
}
options="getOnlyINDIA"
通过将国家/地区“ca”更改为“in”查看此演示,这将有所帮助