Issue Solved: HTML5 Geolocation not working in chrome

If your chrome version is 50, then you’ll encounter that HTML5 Geolocation API is not working. In Chrome version 50, HTML5 Geolocation delivered over HTTP no longer supported by Chrome. The getcurrentposition() and watchposition() are deprecated on insecure origins in Chrome 50.

The web page need to be served over HTTPS for using getcurrentposition() of Geolocation API. For example, web page URL (insecure origins) is not allowed to use HTML5 Geolocation API and web page URL (secure origins) is allowed to use HTML5 Geolocation API.

To handle the insecure origins issue in chrome, you can use the following JavaScript.

    function(success) {
        /* Location tracking code */
    function(failure) {
        if(failure.message.indexOf("Only secure origins are allowed") == 0) {
            alert('Only secure origins are allowed by your browser.');

Leave a reply