11540 sujets

JavaScript, DOM et API Web HTML5

Bonjour;
Depuis un certain temps, la géolocalisation ne fonctionne pas chez moi ??
J'ai essayés les démos existants, qui marchaient avant, maintenant ça marche pas ??

Merci d'avance pour votre aide.
Bonsoir

Je penses que cela vient de ton navigateur. Tu as du la désactivé pour le site ou de façon global.

Si tu utilise Firefox, voila la faq qui t'aidera : http://www.mozilla.org/fr/firefox/geolocation/
Voir :
- Comment annuler une permission que j'ai accordée à un site ?
- Comment désactiver de façon permanente la fonctionnalité de géolocalisation ?
Salut ami, m'excuse pour le retard, et merci pour la réponse.
En faite, aujourd'hui, j'ai un autre comportement:
Par internet, ça marche. mais en local (avec apache) ça marche pas.

J'ai utilisé la même page que j'ai copié dans le dossier du serveur local; après je lance localhost/pagedegeolocalisation.
Mais, c'est pas le problème.

Des fois ça marche, des fois ça marche pas, c'est instable.

Par exemple aujourd'hui, ça marche pas du tout ; j'ai essayé plusieurs exemples que j'ai trouvé sur internet.
exemple:

<!DOCTYPE html>
<html>
  <head>
    <title>Google Maps JavaScript API v3 Example: Map Geolocation</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
	<link href="default.css" rel="stylesheet">
    <!--
    Include the maps javascript with sensor=true because this code is using a
    sensor (a GPS locator) to determine the user's location.
    See:  https://developers.google.com/apis/maps/documentation/javascript/basics#SpecifyingSensor
 
    -->
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>
 
    <script>
      var map;
 
      function initialize() {
        var mapOptions = {
          zoom: 6,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);
 
        // Try HTML5 geolocation
        if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude,
                                             position.coords.longitude);
 
            var infowindow = new google.maps.InfoWindow({
              map: map,
              position: pos,
              content: 'Location found using HTML5.'
            });
 
            map.setCenter(pos);
          }, function() {
            handleNoGeolocation(true);
          });
        } else {
          // Browser doesn't support Geolocation
          handleNoGeolocation(false);
        }
      }
 
      function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
          var content = 'Error: The Geolocation service failed.';
        } else {
          var content = 'Error: Your browser doesn\'t support geolocation.';
        }
 
        var options = {
          map: map,
          position: new google.maps.LatLng(60, 105),
          content: content
        };
 
        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
      }
 
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>