Skip to content

Commit 336de47

Browse files
committed
ICL-1554 修复leaflet组件:地址匹配与图层要素查询,被查询的图层要素在页面消失的问题 review by luox
1 parent 2ee1c7e commit 336de47

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/leaflet/components/search/SearchView.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,10 @@ export var SearchView = ComponentsViewBase.extend({
664664
this.map.closePopup();
665665
//若当前是查询图层的结果,则不删除图层,只修改样式
666666
!this.isSearchLayer && this.map.removeLayer(this.searchResultLayer);
667-
this._selectMarkerFeature && this.map.removeLayer(this._selectMarkerFeature);
668-
this._selectFeaturethis && this.map.removeLayer(this._selectFeature);
667+
if (this._selectMarkerFeature) {
668+
this.map.removeLayer(this._selectMarkerFeature);
669+
this.isSearchLayer && this._selectFeature.addTo(this.map);
670+
}
669671
this._selectMarkerFeature = null;
670672
this._selectFeature = null;
671673
this.searchResultLayer = null;
@@ -737,7 +739,7 @@ export var SearchView = ComponentsViewBase.extend({
737739
return L.marker(latlng, {
738740
icon: L.divIcon({
739741
className: 'component-select-marker-icon',
740-
iconAnchor: [15, 0]
742+
iconAnchor: [15, 42]
741743
})
742744
})
743745
},
@@ -755,7 +757,8 @@ export var SearchView = ComponentsViewBase.extend({
755757
attributes: layer.feature.properties
756758
})).getElement()
757759
}, {
758-
closeOnClick: false
760+
closeOnClick: false,
761+
offset: [0, -36]
759762
}).openPopup().addTo(this.map);
760763

761764
this._flyToBounds(this.searchResultLayer.getBounds());

test/leaflet/components/search/SearchViewSpec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,16 @@ describe('leaflet_search_SearchView', () => {
192192
document.getElementsByClassName('component-citytabpag__content')[0].childNodes[0].click();
193193

194194
})
195+
196+
it('clearSearchResult', (done) => {
197+
poiSearch._selectMarkerFeature = {};
198+
poiSearch.isSearchLayer = true;
199+
poiSearch._selectFeature = {
200+
addTo: () => {}
201+
};
202+
const spy = spyOn(poiSearch._selectFeature, 'addTo');
203+
poiSearch.clearSearchResult();
204+
expect(spy).toHaveBeenCalled();
205+
done();
206+
})
195207
})

0 commit comments

Comments
 (0)