A
A
Andrew2016-03-20 21:16:44
Yandex maps
Andrew, 2016-03-20 21:16:44

How to style search field in yandex maps api?

The Yandex Maps API has a ymaps.control.SearchControl. You need to change its appearance a little - the font, the color of the backdrop, the indents. At the same time, I would like not to lose the existing functionality (hint when entering, search by pressing Enter).
I suspect that you need to change the property formLayout, but what arguments are available in it and how to reuse the drop-down list of hints is not clear.
Is there an example somewhere on how this is done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2016-03-23
@impwx

Figured out how to do it. Perhaps someone will come in handy.
1. We make up the form the way it should look.
2. Create a template using ymaps.templateLayoutFactory.createClass.
3. In the method , we buildsubscribe to the event submitof the form, in the handler we do the following:

searchCallback: function(e) {
  e.preventDefault();

  var ctrl = this.getData().control;
  ctrl.search($('#search-field').val());
}

4. In the same place we create ymaps.SuggestView, pass it the id of the search field (without the grid).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question