0

Hello I made a web app that shows the current location, the final destination and some waypoints in between that the user needs to visit. Since some days google changed something about its privacy? And now it doesnt load my map anymore. The only error i get is

getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

I followed the link but i don't get any wiser of it. The fiddle of my code is here:

https://jsfiddle.net/pquumq74/

if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(function(position) {
                        curLoc = new google.maps.LatLng(
                            position.coords.latitude,
                            position.coords.longitude
                        );

                        var request = {
                            origin: curLoc,
                            destination: fabriek,
                            travelMode: google.maps.TravelMode.DRIVING,
                            waypoints: waypts,
                            optimizeWaypoints: true
                        };

                        var infowindow = new google.maps.InfoWindow({
                            content: "Dit ben jij"
                        });

                        var bestuurderIcon = new google.maps.MarkerImage('marker-bestuurder.png',
                            null,
                            null,
                            null,
                            new google.maps.Size(40, 50));

                        var marker = new google.maps.Marker({
                            position: curLoc,
                            icon: bestuurderIcon,
                            map: map,
                            title: 'Dit ben jij',
                            animation: google.maps.Animation.DROP
                        });
                        marker.addListener('click', function() {
                            infowindow.open(map, marker);
                        });

                        directionsService.route(request, function(response, status) {
                            if (status == google.maps.DirectionsStatus.OK) {
                                directionsDisplay.setDirections(response);
                                // navigeer naar volgende punt met google applicatie op device
                                document.getElementById("gohere").href = "google.navigation:q=" + response.routes[0].legs[0].end_address;



                            }
                        });
                    });
                }
Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
Pixelsquare
  • 173
  • 2
  • 14
  • possible duplicate of [Chrome navigator.geolocation.getCurrentPosition() error 403](http://stackoverflow.com/questions/32329464/chrome-navigator-geolocation-getcurrentposition-error-403) – geocodezip Sep 01 '15 at 13:51

1 Answers1

2

The warning(it's not an error) means.

In the future(not now) it will not be possible to use getCurrentPosition in conjunction with insecure connections.

In the linked fiddle you shouldn't see this warning, because it's secure

https://jsfiddle.net/pquumq74/

but you should see the message at

http://jsfiddle.net/pquumq74/

(Note the difference between the protocols, when you use the first link and retrieve the page-details you'll see that the connection is encrypted...secure)

When you get an error PERMISSION_DENIED(I wonder where, you didn't define a failure-callback) it simply means that the browser/user didn't grant access to geolocation, this is not related to the warning about about the insecure connection.

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
  • Hi, but how do you get the coordenates? In my case, I call getCurrentPosition and I get the Warning but I don't get the latitude and longitude, even if I agree to share my position... – Patrick Sep 01 '15 at 13:26
  • there is no guarantee for a sucessfull geocoding, when you've granted access and don't get a result usually your location couldn't be detected. Use the error-callback (2nd argument of getCurrentPosition ) to get details about the geolocation-error – Dr.Molle Sep 01 '15 at 13:33
  • I get code: 2, message: "Network location provider at 'https://www.googleapis.com/' : Returned error code 403.". Any idea why? It has been always working until today... – Patrick Sep 01 '15 at 13:47
  • the code 2 means: POSITION_UNAVAILABLE see: http://www.w3.org/TR/geolocation-API/#position_error_interface – Dr.Molle Sep 01 '15 at 14:30
  • Very strange because has soon the warning appeared, I was no more able to determine the position in the same place I have been always to be able to, even in a remote server where it was always working also... – Patrick Sep 01 '15 at 14:32