When I try to get the current position
navigator.geolocation.getCurrentPosition(handleCoordinates, handleError, {timeout:10000})
it returns
"Network location provider at '/' : Returned error code 400."
Can somebody suggest any possible ways?
When I try to get the current position
navigator.geolocation.getCurrentPosition(handleCoordinates, handleError, {timeout:10000})
it returns
"Network location provider at 'https://www.googleapis./' : Returned error code 400."
Can somebody suggest any possible ways?
Share Improve this question edited Dec 23, 2017 at 21:49 Daniel Puiu 9616 gold badges21 silver badges29 bronze badges asked Dec 23, 2017 at 20:34 VitoVito 3301 gold badge3 silver badges11 bronze badges2 Answers
Reset to default 6You should configure correct google api key to request google related services in chromium.
https://github./electron/electron/blob/master/docs/api/environment-variables.md#google_api_key
https://github./electron/electron/issues/9420
Initializing Google Api Key In Main JS file :
app.whenReady().then(() => {
process.env.GOOGLE_API_KEY = 'AI.....'
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
and Calling below method in preload js :
if (navigator.geolocation) {
console.log('with in if block');
navigator.geolocation.getCurrentPosition((position) => {
console.log("Latitude : " + position.coords.latitude);
} ,(err ) =>{
console.log("getting error : " + err.message);
} , {timeout:10000})
} else {
console.log('with in else block');
}
//enter code here: "User has not allowed access to system location."