GetcurrentPosition doesn't work once deployed
Asked Answered
D

1

0

I'm trying to initialize a Map centered and with a marker on current user's position. In local everything fine, but when i deploy the html page to Google Appengine, it shows just the map without the geolocalization... Where I'm wrong? Thanks!

var marker;
  function initAutocomplete() {
    var map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: 44.415, lng: 10.374},
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function (position) {
            initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            map.setCenter(initialLocation);
            marker = new google.maps.Marker({
                icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                map: map,
                draggable: true,
                animation: google.maps.Animation.DROP,
                position: {lat: position.coords.latitude, lng: position.coords.longitude}
              });
              marker.addListener('click', toggleBounce);
        });


        }
Dedrick answered 12/5, 2016 at 16:40 Comment(3)
Is it deployed over HTTPS:? What browser are you testing in?Pinchcock
1-dot-glance-1294.appspot.com/mappa.html testing on chromeDedrick
Look in the console, in addition to the javascript error, you will see: getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See sites.google.com/a/chromium.org/dev/Home/chromium-security/… for more details.Pinchcock
P
2

Chrome no longer supports geolocation on insecure origins. You must use HTTPS:// if you want to use geolocation.

See the message in the console:

getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins for more details.`

Pinchcock answered 12/5, 2016 at 21:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.