* @function SearchView.prototype._initView * @description 创建地址匹配或图层要素查询组件。 * @override * @returns {HTMLElement} * @private
()
| 90 | * @private |
| 91 | */ |
| 92 | _initView() { |
| 93 | // self 便于 this 对象的使用 |
| 94 | const self = this; |
| 95 | const div = document.createElement("div"); |
| 96 | div.setAttribute("class", "component-search-container"); |
| 97 | |
| 98 | //外框 |
| 99 | const poiContainer = document.createElement("div"); |
| 100 | poiContainer.setAttribute("class", "component-search"); |
| 101 | //主体 |
| 102 | //---------下拉框: |
| 103 | const poiSettings = document.createElement("div"); |
| 104 | poiSettings.setAttribute("class", "component-search__settings"); |
| 105 | //下拉框 |
| 106 | const poiSearchName = document.createElement("div"); |
| 107 | //由View 维护,进行交互操作 |
| 108 | poiSearchName.setAttribute("class", "component-search__settings__name"); |
| 109 | //poiSettings.innerHTML 通过下拉框选项改变 |
| 110 | |
| 111 | poiSettings.appendChild(poiSearchName); |
| 112 | |
| 113 | //下拉标记 |
| 114 | const triangleIcon = document.createElement("span"); |
| 115 | triangleIcon.setAttribute("class", "supermapol-icons-solid-down-triangle"); |
| 116 | poiSettings.appendChild(triangleIcon); |
| 117 | |
| 118 | //城市地址匹配页面, 以及图层查询页面 |
| 119 | //城市地址匹配页面: |
| 120 | let citySelect = null; |
| 121 | if (this.options.isGeoCoding) { |
| 122 | const cityTabsPageObj = new CityTabsPage({ |
| 123 | config: this.options.cityConfig |
| 124 | }); |
| 125 | citySelect = cityTabsPageObj.getElement(); |
| 126 | //点选城市名,修改显示,并执行定位城市查询【城市列表列表点击事件】 |
| 127 | cityTabsPageObj.content.onclick = (e) => { |
| 128 | if (e.target.nodeName === "SPAN" && e.target.innerText) { |
| 129 | this.viewModel.panToCity(e.target.innerHTML); |
| 130 | this.messageBox.closeView(); |
| 131 | poiSearchName.removeChild(poiSearchName.firstChild); |
| 132 | poiSearchName.insertBefore(document.createTextNode(e.target.innerHTML), poiSearchName.firstChild); |
| 133 | this.isSearchLayer = false; |
| 134 | } |
| 135 | }; |
| 136 | //支持城市地址匹配,则初始化显示配置的第一个城市名: |
| 137 | poiSearchName.appendChild(document.createTextNode(cityTabsPageObj.content.getElementsByTagName("span")[0].innerText)); |
| 138 | } |
| 139 | |
| 140 | //图层查询页面:写法是为了为了代码可读性 |
| 141 | const layersSelect = function () { |
| 142 | const layersSelect = document.createElement("div"); |
| 143 | layersSelect.setAttribute("class", "component-search__layers"); |
| 144 | |
| 145 | const layersContent = document.createElement("div"); |
| 146 | layersContent.setAttribute("class", "component-search-layers-content"); |
| 147 | layersSelect.appendChild(layersContent); |
| 148 | |
| 149 | //header todo 两个选项的功能暂没用到,先关闭,后续用到再打开 |
nothing calls this directly
no test coverage detected