0

I've integrated mapmyindia APIs into my website and whenever I reload the page it is showing popup "mywebsite wants to know your location" with allowing and block button options.

If I click block button then it shows another popup "MapmyIndia does not have permission to view your location." which I don't want it to show up. so I want to know how to hide this popup using php code.

I tried:

window.webkitNotifications.hide()
window.PopupNotifications.hide()

I expect the popup to be hidden.

recnac
  • 3,744
  • 6
  • 24
  • 46
Andrew
  • 35
  • 1
  • 1
  • 5
  • If you are looking for location, look in the input class library for ip_address. Then use the ip for location – Brad May 12 '19 at 00:56

1 Answers1

0

I fear there is a lot of misunderstanding on your part.

First of all, PHP is a backend language, meaning it runs on the server and not on the client (= the browser). PHP (with the CodeIgniter framework) is actually used to generate HTML page containing CSS and JavaScript. Hence why PHP can't interact directly with the browser.

JavaScript is the programming language of the frontend, which run directly on the client (the browser) and directly interact with the user.

Indeed, the 2 lines of code you said you tried are JavaScript code.

So the question would rather be "how to hide browser location permission popup using JavaScript?"

And here is another misunderstanding : luckily, you simply can't. And that's actually good.

When asking for geolocation, any browser will automatically ask user permission to do so. The only thing you can do is wait, hope they accept, and handle the case when they refuse.

There is this good article from MDN explaining why permission are needed, and how they are implemented.

Websites can already track us enough as it is on the web, thanks goodness they can't just get our exact GPS coordinate without asking our permission.

Indigo
  • 745
  • 5
  • 16
  • hi thanks for your prompt response. what i mean to say is javascript but typed php by mistake. yes you are correct. actually my client doesn't want that annoying popup whenever they reload the page. so m still expecting for better suggestions. thanks – Andrew May 11 '19 at 15:20
  • This "annoying popup" as you say is *by design*. You will not find any way to circumvent it (and even if you did find something, Google would patch it soon enough). – Indigo May 11 '19 at 15:50
  • This is a non-issue. If your client accept once the geolocation access, then he will no longer see the request. However, if he blocks, of course it stays blocked! – Indigo May 11 '19 at 15:51