I'm working on a cordova app
on which I have to locate the user
latitude and longitude. Using the geolocation plugin, it works fine on android devices but it display an alert asking for permission from user in iOS
. When I used the simulator I get this alert message:
Users/user/Library/Developer/CoreSimulator/Devices/783A2EFD-2976-448C-8E4E-841C985D337D/data/Containers/Bundle/Application/EFC846BB-4BA3-465C-BD44-575582E649FC/app_name.app/www/index.html would like to use your current location.
I have seen topic talking about this problem like: this but none of the provided solutions works for me.
this is my geolocation function:
function loadMyCoordonnee() {
if (navigator.geolocation) {
navigator.geolocation
.getCurrentPosition(
function(position) {
var myLatlng = new google.maps.LatLng(
position.coords.latitude,
position.coords.longitude);
window.localStorage.setItem("lattitude",
position.coords.latitude);
window.localStorage.setItem("longitude",
position.coords.longitude);
console.log('lattitude : '
+ window.localStorage.getItem("lattitude"));
console.log('longitude : '
+ window.localStorage.getItem("longitude"));
}, function(error) {
var myLatlng = new google.maps.LatLng(
47.120547402337465, 2.651801171874922);
window.localStorage.setItem("lattitude",
47.1205474023374655);
window.localStorage.setItem("longitude",
2.651801171874922);
});
} else {
window.location = "index.html";
}
}
and here where I called this function:
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
loadMyCoordonnee();
//app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
Is there any way to change the text of the alert or to disable this alert?
Aucun commentaire:
Enregistrer un commentaire