【发布时间】:2018-07-17 11:04:41
【问题描述】:
我已将 google maps API 与我的应用程序集成以提供自动完成建议,它在我的笔记本电脑 (Ubuntu) 所有浏览器上也能正常工作。但是,最近我用 iPad 和 iPhone 进行了测试,它不起作用。我无法点击建议的地点。我正在使用 AngularJS,我的代码 sn-p 如下:
HTML
<div class="row">
<div class="col-md-6">
<form name="searchForm" ng-submit="fillInAddress()">
<div class="input-group well">
<input type="text" class="form-control" id="autocomplete" name="city" placeholder="Enter your city"
onFocus="geolocate()" required />
<span class="input-group-btn">
<button class="btn btn-primary" type="submit" ladda="ldloading.slide_left" data-style="slide-left" data-spinner-color="#000000"
ng-disabled="searchForm.$invalid">
<i class="fa fa-search"></i> Search
</button>
</span>
</div>
</form>
</div>
</div>
JS
var placeSearch, autocomplete;
function initAutocomplete() {
autocomplete = new google.maps.places.Autocomplete((document.getElementById('autocomplete')),
{types: ['geocode']});
autocomplete.addListener('place_changed', fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
var place = autocomplete.getPlace();
locationfilter.lat=place.geometry.location.lat();
locationfilter.lon=place.geometry.location.lng();
$scope.getOrders($scope.reportParams,locationfilter);
}
$scope.getOrders = function(pagination, locationfilter) {
$scope.working = true;
sliveorders
.getLocOrders(pagination, locationfilter)
.then(function(res) {
$scope.Orders=res.data;
$scope.totalItems=res.total;
$scope.working = false;
})
.catch(function(err) {
console.log('Location search err:', err);
$scope.working = false;
});
}
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
});
}
};
initAutocomplete();
【问题讨论】:
-
你能创建一个小提琴或 plnkr 来重现你的问题吗?
button和type"submit"不工作吗?意思是:ng-submit不工作? -
是的,带有 type="submit" 的按钮不起作用记住它在笔记本电脑/台式机浏览器中工作它只是在 ipad、iphone 等 iOS 设备(笔记本电脑除外)上不起作用
-
你能创建一个小提琴或 plnkr 来重现你的问题吗?我
-
你在使用 ngTouch 吗?
-
@kannan 不,它适用于 AngularJS (ngmap.github.io) 和 Angular2 (github.com/ng2-ui/map),请检查一下
标签: javascript ios angularjs google-maps ipad