Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Как убрать локацию по ip? (https://javascript.ru/forum/misc/72829-kak-ubrat-lokaciyu-po-ip.html)

spinastr 01.03.2018 14:30

Как убрать локацию по ip?
 
Как убрать локацию по ip, вписать город в ручную?

город уже вписал, но локацию убрать не могу

<link rel='stylesheet' href="https://cdn.rawgit.com/erikflowers/weather-icons/master/css/weather-icons.css" rel="stylesheet">
 <link rel='stylesheet' href="https://cdn.rawgit.com/erikflowers/weather-icons/master/css/weather-icons-wind.css" rel="stylesheet">

 <div id='place'></div>
 <div id='temperature'></div>
 <div id='degree' class='Celsius'>&deg;<span id='degree-system'>C</span></div>
 <div id='weather'></div>
 <i class='wi'></i>




<script>

var coord;
var APIcall;
var FarTemp;
var CelTemp;

function showWeather(json) {
 console.log(json.weather[0].main.toLowerCase());
 FarTemp = Math.round(json.main.temp * 1.8 + 32);
 CelTemp = Math.round(json.main.temp);
 var weatherIcon = 'wi-owm-' + json.weather[0].id;
 $('#temperature').text(CelTemp);
 $('#weather').text(json.weather[0].description);
 $('.wi').addClass(weatherIcon);
};

function showPlace(json) {
 console.log(json);
 var coords = json.loc.split(',');
 $('#place').text((json.city + ', ' + json.country));
 APIcall = 'https://api.openweathermap.org/data/2.5/weather?q=Mikhaylov&APPID=2bae515a0124fef864cf38e0f2986b32&units=metric&lang=ru&lat=' + coords[0] + '&lon=' + coords[1];
 $.getJSON(APIcall, showWeather);
}

$.getJSON('https://ipinfo.io/json', showPlace);

$('#degree').click(function () {
 if ($('#degree').hasClass('Celsius')) {
 $('#temperature').text(FarTemp);
 $('#degree-system').text('F');
 $('#degree').removeClass('Celsius');
 $('#degree').addClass('Fahrenheit');
 } else {
 $('#temperature').text(CelTemp);
 $('#degree-system').text('C');
 $('#degree').removeClass('Fahrenheit');
 $('#degree').addClass('Celsius');
 }
});
</script>

Dilettante_Pro 02.03.2018 10:22

<link rel='stylesheet' href="https://cdn.rawgit.com/erikflowers/weather-icons/master/css/weather-icons.css" >
 <link rel='stylesheet' href="https://cdn.rawgit.com/erikflowers/weather-icons/master/css/weather-icons-wind.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

 <div id='place'></div>
 <div id='temperature'></div>
 <div id='degree' class='Celsius'>&deg;<span id='degree-system'>C</span></div>
 <div id='weather'></div>
 <i class='wi'></i>




<script>

var coord;
var APIcall;
var FarTemp;
var CelTemp;

function showWeather(json) {
 console.log(json.weather[0].main.toLowerCase());
 FarTemp = Math.round(json.main.temp * 1.8 + 32);
 CelTemp = Math.round(json.main.temp);
 var weatherIcon = 'wi-owm-' + json.weather[0].id;
 $('#temperature').text(CelTemp);
 $('#weather').text(json.weather[0].description);
 $('.wi').addClass(weatherIcon);
};

function showPlace(place) {
 $('#place').text((place));
 APIcall = 'https://api.openweathermap.org/data/2.5/weather?q=' +place + '&APPID=2bae515a0124fef864cf38e0f2986b32&units=metric&lang=ru';
 $.getJSON(APIcall, showWeather);
}

showPlace('Novosibirsk,ru');

$('#degree').click(function () {
 if ($('#degree').hasClass('Celsius')) {
 $('#temperature').text(FarTemp);
 $('#degree-system').text('F');
 $('#degree').removeClass('Celsius');
 $('#degree').addClass('Fahrenheit');
 } else {
 $('#temperature').text(CelTemp);
 $('#degree-system').text('C');
 $('#degree').removeClass('Fahrenheit');
 $('#degree').addClass('Celsius');
 }
});
</script>

spinastr 07.03.2018 03:29

Dilettante_Pro,
спасибо


Часовой пояс GMT +3, время: 07:59.