Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Chrome Extension Geo location Permission

getting error : Is the 'geolocation' permission appropriate? See https://developer.chrome.com/extensions/manifest.html#permissions.

Trying to get user location coordinate for chrome extension app and i am getting permission error although i have given permission in manifest.json still getting error Is the 'geolocation' permission appropriate? See https://developer.chrome.com/extensions/manifest.html#permissions.

my code: index.js

navigator.geolocation.getCurrentPosition (function (position) {
    console.log(position.coords.latitude, position.coords.longitude);
    const lat=position.coords.latitude;
    const lng=position.coords.longitude;
    fetch("https://api.opencagedata.com/geocode/v1/json?key=************&q=" +lat + "+" + lng + "&pretty=1&no_annotations=1").then(res=> res.json()).then(place=>{
    city=(place.results[0].components.city).toUpperCase();
    console.log(city);
    country=((place.results[0].components.country).toUpperCase()).substring(0,2);
    console.log(country)

   
    fetch(url+city+','+country+'&appid='+key).then(data=>data.json()).then(weather=>{
        const wtemp=weather.main;
        const wsys=weather.sys;
        var sunrise=new Date(wsys.sunrise*1000).toLocaleTimeString();
       weatherWidgetRow1=document.getElementById('weatherWidgetRow1');
       weatherWidgetRow1.innerHTML=`${city}<br>`+((wtemp.temp-273).toFixed(0))+`<sup>o </sup>C`;
       
       weatherWidgetRow2=document.getElementById('weatherWidgetRow2');
       weatherWidgetRow2.innerHTML='min : '+((wtemp.temp_min-273).toFixed(0))+`<sup>o</sup> C`+` and max : ${(wtemp.temp_max-273).toFixed(0)}<sup>o</sup> C`;
    
       weatherWidgetRow3=document.getElementById('weatherWidgetRow3');
       weatherWidgetRow3.innerHTML=`Humidity: ${wtemp.humidity} %`;
    
       weatherWidgetRow4=document.getElementById('weatherWidgetRow4');
       weatherWidgetRow4.innerHTML=`Sunrise : ${sunrise} <br>  Sunset : ${new Date(wsys.sunset*1000).toLocaleTimeString()} `;
    
    });

});
}, console.error(),
{ maximumAge: 600_000 }
);

manifest.json

{
    "name": "WeatherExtension",
    "version": "0.0.1",
    "manifest_version": 2,
    "browser_action":{
        "default_popup": "index.html",
        "defaul_icon": "logo.png"
    },
    "icons":{
        "128": "logo.png"
    },
    "permissions" : ["geolocation"] 
}

where i am wrong ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda