0
我想問一下,我如何確定地理位置並使用php將用戶重定向到他們的地理網頁。 我知道重定向就像。如何識別地理位置和用php重定向頁面?
<?php
header('Location: mypage.php');
?>
我很欣賞你的幫助
我想問一下,我如何確定地理位置並使用php將用戶重定向到他們的地理網頁。 我知道重定向就像。如何識別地理位置和用php重定向頁面?
<?php
header('Location: mypage.php');
?>
我很欣賞你的幫助
<html>
<head>
<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
<script type="text/javascript">
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var latlng = new google.maps.LatLng(lat, lng);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
alert(results[7].formatted_address);
}
} else {
alert("Geocoder failed due to: " + status);
}
});
});
} else {
alert("Geolocation services are not supported by your browser.");
}
</script>
</head>
<body>
</body>
</html>
使用這個你可以得到座標的位置,然後使用谷歌API,你可以有國家代碼,因此,您可以發送用戶對特定
頁
這可能會讓你開始:http://stackoverflow.com/questions/6320674/get-a-users-state-with-geolocation –