Copier le code du code comme suit:
<!
<html>
<body>
<p id = "Demo"> Cliquez sur ce bouton pour obtenir votre position: </p>
<bouton onclick = "getLocation ()"> Essayez-le </button>
<script src = "http://api.map.baidu.com/api?v=1.4" type = "text / javascript"> </ script>
<cript>
var x = document.getElementById ("Demo");
fonction getLocation () {{)
if (if (navigator.geolocation) {
Navigator.Geology.getCurrentPosition (showPosition);
} Autre {
Alert ("Votre navigateur ne prend pas en charge le positionnement géographique");
}
}
Fonction ShowPosition (position) {
Lat = position.coords.Latitude;
lon = positif.coords.longitude;
// var map = new bmap.map ("conteneur");
var point = new BMAP.point (long, lat);
//map.CenterandZoom (point, 15);
//map.enablesCrollWeelZoom ();
var gc = new bmap.geocoder ();
gc.getLocation (point, fonction (rs) {
var addcomp = Rs.AddressComponents;
Alert (addcomp.province + "," + addcomp.city + "," + addcomp.district + "," + addcomp.street);
});
}
</cript>
</docy>
</html>