S
S
Sergey Kravchenko2016-07-15 11:17:23
PHP
Sergey Kravchenko, 2016-07-15 11:17:23

How to change the name of the city depending on where the visitor is located?

The site lists the city as take.ms/5D8ez , and it is necessary to change the name of the city depending on where the visitor is located. Maybe someone knows how this is done.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Kravchenko, 2016-07-17
@Vinnica

Thanks who helped. found a simple solution using Yandex

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script charset="utf-8" src="http://api-maps.yandex.ru/1.1/index.xml?key=API-ключ" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
if (YMaps.location.city != '') {
  $('.country span').html(YMaps.location.country);
  $('.region span').html(YMaps.location.region);
  $('.city span').html(YMaps.location.city);
}
else {
  $('.title').html('Яндекс ничего не вернул.');
}
});
</script>

A
Artem Ignatovsky, 2016-07-15
@ArtemIgnatovsky

You need to cut GeoIP. The bases are available for free, but they are not very good, there are also paid services.
And the principle is something like this: a client visits the site, you pull his IP and search the database.

A
Ad4ptec, 2016-07-16
@Ad4ptec

Here is a not bad geoip service: ip-api.com/docs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question