Добрый вечер!
Проблема следующая:
При построении маршрута через поиск (найти адрес, выбрать его, выбрать как добраться) отображается информационный балун,
при повторном поиске отображается балун с информацией о маршруте и кнопка подробнее.
Как сделать так, чтобы с первого раза отображался балун с информацией о маршруте и кнопка подробнее?
Код скрипта:
ymaps.ready(function() { var targetCoords = [55.6785, 37.782], myMap = new ymaps.Map('map1', { center: [55.6782, 37.768], zoom: 16, boundsAutoApply: true }, { searchControlResults: 1, searchControlNoCentering: true, buttonMaxWidth: 200 }), targetPoint = new ymaps.Placemark(targetCoords, { iconContent: '' }, { preset: 'islands#dotCircleIcon', iconColor: '#8224e3' }), searchControl = myMap.controls.get('searchControl'), geolocationControl = myMap.controls.get('geolocationControl'), routeTypeSelector = new ymaps.control.ListBox({ data: { content: 'Как добраться' }, items: [new ymaps.control.ListBoxItem('На автомобиле'), new ymaps.control.ListBoxItem('Общественным транспортом'), new ymaps.control.ListBoxItem('Пройти пешком')], options: { itemSelectOnClick: false } }), autoRouteItem = routeTypeSelector.get(0), masstransitRouteItem = routeTypeSelector.get(1), pedestrianRouteItem = routeTypeSelector.get(2), sourcePoint, currentRoute, currentRoutingMode; myMap.geoObjects.add(targetPoint); myMap.behaviors.disable('scrollZoom'); myMap.controls.add(routeTypeSelector); autoRouteItem.events.add('click', function(e) { createRoute('auto', e.get('target')); }); masstransitRouteItem.events.add('click', function(e) { createRoute('masstransit', e.get('target')); }); pedestrianRouteItem.events.add('click', function(e) { createRoute('pedestrian', e.get('target')); }); myMap.events.add('click', onMapClick); searchControl.events.add('resultshow', onSearchShow); geolocationControl.events.add('locationchange', onGeolocate); function onMapClick(e) { clearSourcePoint(); sourcePoint = new ymaps.Placemark(e.get('coords'), { iconContent: 'Отсюда' }, { preset: 'islands#greenStretchyIcon' }); myMap.geoObjects.add(sourcePoint); createRoute(); } function onSearchShow(e) { clearSourcePoint(true); sourcePoint = searchControl.getResultsArray()[e.get('index')]; createRoute(); } function onGeolocate(e) { clearSourcePoint(); sourcePoint = e.get('geoObjects').get(0); createRoute(); } function clearSourcePoint(keepSearchResult) { if (!keepSearchResult) { searchControl.hideResult(); } if (sourcePoint) { myMap.geoObjects.remove(sourcePoint); sourcePoint = null; } } function createRoute(routingMode, targetBtn) { if (routingMode) { if (routingMode == 'auto') { masstransitRouteItem.deselect(); pedestrianRouteItem.deselect(); } else if (routingMode == 'masstransit') { autoRouteItem.deselect(); pedestrianRouteItem.deselect(); } else if (routingMode == 'pedestrian') { autoRouteItem.deselect(); masstransitRouteItem.deselect(); } targetBtn.select(); routeTypeSelector.collapse(); } else if (currentRoutingMode) { routingMode = currentRoutingMode; } else { return; } if (!sourcePoint) { currentRoutingMode = routingMode; geolocationControl.events.fire('press'); return; } clearRoute(); currentRoutingMode = routingMode; currentRoute = new ymaps.multiRouter.MultiRoute({ referencePoints: [sourcePoint, targetPoint], params: { routingMode: routingMode, boundsAutoApply: true } }); currentRoute.model.events.add('requestsuccess', function() { currentRoute.getWayPoints().get(0).events.fire('click'); }); myMap.geoObjects.add(currentRoute); } function clearRoute() { myMap.geoObjects.remove(currentRoute); currentRoute = currentRoutingMode = null; } myMap.behaviors.disable('scrollZoom'); });
Заранее благодарю!