// --------------------------------------------------------- // VSearchWidget class // Плагин для реализации поиска. // --------------------------------------------------------- VSearchWidget.prototype._width = null; VSearchWidget.prototype._height = null; VSearchWidget.prototype._visible = false; /** HTMLelement. */ VSearchWidget.prototype._div; VSearchWidget.prototype._box_fields; VSearchWidget.prototype._hint; VSearchWidget.prototype._address; VSearchWidget.prototype._submit_button; VSearchWidget.prototype._results; VSearchWidget.prototype._layer; VSearchWidget.prototype._marker; /** * @category = Plugins * @class * Плагин для реализации поиска. Отображает поисковую форму. * @params {HTMElement} div html элемент div, в котором будет отображаться поисковая форма. * @constructor */ function VSearchWidget(div) { this._div = div; this.init(); _VISICOM_SearchWidget_layer = new VLayer(); mapEngine.addLayer(_VISICOM_SearchWidget_layer); } /** * Инициализация. */ VSearchWidget.prototype.init = function() { this._width = this._div.offsetWidth; this._height = this._div.offsetHeight; if (this._width < 200) this._width = 200; if (this._height < 80) this._height = 80; var me = this; this._div.style.margin = '0px'; this._div.style.padding = '0px'; this._div.style.position = 'relative'; this._div.style.zIndex = '102'; this._div.style.width = this._width + 'px'; this._div.style.height = this._height + 'px'; //this._div.style.border = '1px solid #acbedf'; // Подсказка this._hint = document.createElement('div'); this._hint.style.fontSize = '12px'; this._hint.style.fontFamily = 'Verdana'; this._hint.style.fontWeight = 'bold'; //this._hint.style.color = '#34547C'; this._hint.style.padding = '0px'; this._hint.style.position = 'relative'; this._hint.style.width = this._width + 'px'; this._hint.style.height = '20px'; this._hint.innerHTML = MSG_SEARCH_ADDRESS; //this._hint.style.border = '1px dashed #acbedf'; // Область для контролов this._box_fields = document.createElement('div'); //this._box_fields.style.margin = '10px 0px 0px 21px'; this._box_fields.style.padding = '0px'; this._box_fields.style.width = this._width + 'px'; this._box_fields.style.height = '50px'; //this._box_fields.style.border = '1px dashed #acbedf'; // Адрес this._address = document.createElement('input'); this._address.id = 'address'; this._address.onkeypress = function(e) { var keynum; if (window.event) { keynum = window.event.keyCode; } else if(e.which) { keynum = e.which; } // Проверка на нажатие клавиши "Enter" if (keynum != 13) return; me._goSearch(); } //this._address.style.border = '1px solid #acbedf'; this._address.style.background = 'url(http://maps.visicom.ua/images/background_field.gif) repeat-x left top'; this._address.style.fontSize = '12px'; this._address.style.fontFamily = 'Verdana'; this._address.style.marginRight = '3px'; //this._address.style.color = 'gray'; this._address.style.width = (this._width - 75) + 'px'; this._address.style.height = '19px'; //this._address.style.verticalAlign = 'top'; // Кнопка "Поиск" this._submit_button = document.createElement('input'); this._submit_button.type = 'button'; this._submit_button.style.width = '70px'; this._submit_button.style.height = '21px'; this._submit_button.value = 'Найти'; this._submit_button.onclick = function(e) { me._goSearch(); } // Результаты this._results = document.createElement('div'); this._results.id = 'results'; this._results.style.fontSize = '12px'; this._results.style.fontFamily = 'Verdana'; //this._results.style.lineHeight = '140%'; this._results.style.overflow = 'auto'; //this._results.style.color = 'black'; //this._results.style.margin = '20px 0px 0px 21px'; this._results.style.padding = '0px'; this._results.style.width = this._width + 'px'; this._results.style.height = (this._height - 60) + 'px'; this._box_fields.appendChild(this._hint); this._box_fields.appendChild(this._address); this._box_fields.appendChild(this._submit_button); } /** * Поиск */ VSearchWidget.prototype._goSearch = function() { _VISICOM_search_moment_id = Math.random(); _VISICOM_findSemantic(); } /** * @public * Отображает форму. */ VSearchWidget.prototype.show = function() { if (this._visible) return; this._div.appendChild(this._box_fields); this._div.appendChild(this._results); mapEngine.resizeViewport(); } /** * @public * Скрывает форму. */ VSearchWidget.prototype.hide = function() { if (!this._visible) return; this._div.removeChild(this._box_fields); this._div.removeChild(this._results); mapEngine.resizeViewport(); } var _VISICOM_search_moment_id = null; var _VISICOM_SearchWidget_layer = null; var _VISICOM_SearchWidget_marker = null; /** * Поиск по адресной строке. */ function _VISICOM_findSemantic() { var _search_moment_id = _VISICOM_search_moment_id; var address = document.getElementById("address").value; var resultDiv = document.getElementById('results'); if (address.length < 3) { // Сообщение "Введите более 2-х символов..." resultDiv.innerHTML = '