複数の通貨をサポートする予定の opencart を使用してサイトを開発しています。通貨は、ユーザーの物理的な場所に基づいて変更する必要があります。つまり、米国から開いた場合、通貨の可視性はドルに設定され、インドの人が開いた場合、INR に設定する必要があります。それは可能ですか?
2783 次
2 に答える
0
これを試して:
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
GetAddress(position.coords.latitude, position.coords.longitude)
}
function GetAddress(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({
'latLng': latlng
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var address = results[1].address_components;
for (var i = 0, iLen = address.length; i < iLen; i++) {
if (address[i].types[0] === 'country') {
var countryName = address[i].long_name;
alert(countryName);
}
}
}
}
});
}
<button type="button" onclick="getLocation()">Get Location</button>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
于 2015-09-22T11:19:50.297 に答える