Skip to content

Commit

Permalink
ICL-1554 修复leaflet组件:地址匹配与图层要素查询,被查询的图层要素在页面消失的问题 review by luox
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Nov 4, 2024
1 parent 2ee1c7e commit 336de47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/leaflet/components/search/SearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,10 @@ export var SearchView = ComponentsViewBase.extend({
this.map.closePopup();
//若当前是查询图层的结果,则不删除图层,只修改样式
!this.isSearchLayer && this.map.removeLayer(this.searchResultLayer);
this._selectMarkerFeature && this.map.removeLayer(this._selectMarkerFeature);
this._selectFeaturethis && this.map.removeLayer(this._selectFeature);
if (this._selectMarkerFeature) {
this.map.removeLayer(this._selectMarkerFeature);
this.isSearchLayer && this._selectFeature.addTo(this.map);
}
this._selectMarkerFeature = null;
this._selectFeature = null;
this.searchResultLayer = null;
Expand Down Expand Up @@ -737,7 +739,7 @@ export var SearchView = ComponentsViewBase.extend({
return L.marker(latlng, {
icon: L.divIcon({
className: 'component-select-marker-icon',
iconAnchor: [15, 0]
iconAnchor: [15, 42]
})
})
},
Expand All @@ -755,7 +757,8 @@ export var SearchView = ComponentsViewBase.extend({
attributes: layer.feature.properties
})).getElement()
}, {
closeOnClick: false
closeOnClick: false,
offset: [0, -36]
}).openPopup().addTo(this.map);

this._flyToBounds(this.searchResultLayer.getBounds());
Expand Down
12 changes: 12 additions & 0 deletions test/leaflet/components/search/SearchViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,16 @@ describe('leaflet_search_SearchView', () => {
document.getElementsByClassName('component-citytabpag__content')[0].childNodes[0].click();

})

it('clearSearchResult', (done) => {
poiSearch._selectMarkerFeature = {};
poiSearch.isSearchLayer = true;
poiSearch._selectFeature = {
addTo: () => {}
};
const spy = spyOn(poiSearch._selectFeature, 'addTo');
poiSearch.clearSearchResult();
expect(spy).toHaveBeenCalled();
done();
})
})

0 comments on commit 336de47

Please sign in to comment.