JSFiddle - React, Tailwind, and code Playground
JavaScript
define(['ready!ymaps', 'jquery', 'module'], function (ymaps, $, module) {
var config = module.config();
function MapView() {
this._map = this._createMap();
this._search = this._createSearch();
this.events = new ymaps.event.Manager();
//this._map.controls.add(this._search);
this._attachHandlers();
};
function getGeometry(request, callback) {
ymaps.ready(function () {
ymaps.geocode(request, {results: 1}).then(function (res) {
//тут console.log возвращает то что нужно
console.log(res.geoObjects.get(0));
callback(res.geoObjects.get(0))
});
});
};
MapView.prototype = {
constructor: MapView,
render: function () {
return this;
},
clear: function () {
this._detachHandlers();
this._map.controls.remove(this._search);
this._map.destroy();
return this;
},
_createMap: function () {
return new ymaps.Map(
config.container,
config.state,
config.options
);
},
_createSearch: function () {
return new ymaps.SuggestView('suggest');
//return new ymaps.control.SearchControl({
// options: {
// useMapBounds: true,
// noCentering: true,
// noPlacemark: true
// }
//});
},
//получение координат
//_getCoordsByName: function (e) {
// ymaps.geocode(e, {results: 1}).then(function (res) {
// return coords = res.geoObjects.get(0).geometry.getCoordinates();
// });
// },
//_getGeo: function (e) {
// ymaps.geocode(e, {results: 1}).then(function (res) {
// //return coords = res.geoObjects.get(0).geometry.getCoordinates();
// //console.log(res.geoObjects.get(0));
// var geometry = res.geoObjects.get(0);
// return geometry;
// });
//},
_attachHandlers: function () {
...