Skip to content

Instantly share code, notes, and snippets.

@alex-boom
Last active July 18, 2016 19:28
Show Gist options
  • Save alex-boom/65e2ca3187745bd614a10b5b15071354 to your computer and use it in GitHub Desktop.
Save alex-boom/65e2ca3187745bd614a10b5b15071354 to your computer and use it in GitHub Desktop.
Геолокация
/*Геолокация. Определение местонахождения клиента(страна, город..) и дальнейшее использование данных местонахождения.
Так же необходимо подключить апи Яндекса в индексную страницу:
<script src="https://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"> </script>
Готовая реализация на странице : http://testall.grytsenko.in.ua/foursoft/thanks.html*/
ymaps.ready(function(){
var geolocation = ymaps.geolocation,
geolocationCountry = geolocation.country;
if(geolocationCountry == "Украина") {
geolocationCountry = "ua";
}
else if(geolocationCountry == "Израиль") {
geolocationCountry = "il";
}
else if(geolocationCountry == "Россия") {
geolocationCountry = "ru";
}
else if(geolocationCountry == "Великобритания") {
geolocationCountry = "gb";
}
else if(geolocationCountry == "Казахстан") {
geolocationCountry = "kz";
}
else if(geolocationCountry == "Узбекистан") {
geolocationCountry = "uz";
}
else if(geolocationCountry == "Беларусь") {
geolocationCountry = "by";
}
else{
geolocationCountry = "ua";
}
$(function(){
$('#phone, #modal-phone').phonecode({
preferCo: geolocationCountry
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment