E
E
exdude2020-02-27 13:05:46
JavaScript
exdude, 2020-02-27 13:05:46

How to resolve conflict between yandex api 2.0 2.1 versions?

Good afternoon!
The site has two functions using yandex.api, these are:
1. User identification on the map;
2. Determining the user's city, and subsequently displaying the city on the page.
Separately, they work fine (

An example is here.
If you remove the commented code, the definition of the city immediately breaks down.

I can’t understand what the conflict is, I ask for help. Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
exdude, 2020-03-03
@exdude

Determining the location of the city Yandex API 2.1

ymaps.ready(init);
  function init(){
    ymaps.geolocation.get({
      provider: 'yandex',
      autoReverseGeocode: true
    }).then(function (result) {
      $('#tow').html('Ваш город: <b style="margin-top: -50px;">'+result.geoObjects.get(0).properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName')+'</b>'); //Определяем ваш город
    });
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question