I have an integrated Google Maps API with my application for autofill suggestions, it works fine on my laptop (Ubuntu) and all browsers. However, I have recently tested the iPad and iPhone, but it does not work. I can not click the proposed places. I am using AngularJS, and my code snippet is below:
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() {
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();
source
share