File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/leaflet/components/search
test/leaflet/components/search Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff 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 ( ) ) ;
Original file line number Diff line number Diff 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} )
You can’t perform that action at this time.
0 commit comments