@@ -39,14 +39,11 @@ L.U.Importer = L.Class.extend({
3939 this . form = template . content . firstElementChild . cloneNode ( true )
4040 this . presetSelect = this . form . querySelector ( '[name="preset-select"]' )
4141 this . fileInput = this . form . querySelector ( '[name="file-input"]' )
42- this . urlInput = this . form . querySelector ( '[name="url-input"]' )
43- this . rawInput = this . form . querySelector ( '[name="raw-input"]' )
4442 this . typeLabel = this . form . querySelector ( '#type-label' )
4543 const helpButton = this . typeLabel . querySelector ( 'button' )
4644 this . map . help . button ( this . typeLabel , 'importFormats' , '' , helpButton )
4745 this . formatSelect = this . form . querySelector ( '[name="format"]' )
4846 this . layerSelect = this . form . querySelector ( '[name="datalayer"]' )
49- this . clearFlag = this . form . querySelector ( '[name="clear"]' )
5047 this . submitInput = this . form . querySelector ( '[name="submit-input"]' )
5148 this . _buildDatalayerOptions ( this . layerSelect )
5249 this . _buildPresetsOptions ( this . presetSelect )
@@ -83,14 +80,17 @@ L.U.Importer = L.Class.extend({
8380 } ,
8481
8582 submit : function ( ) {
86- let type = this . formatSelect . value
83+ const urlInputValue = this . form . querySelector ( '[name="url-input"]' ) . value
84+ const rawInputValue = this . form . querySelector ( '[name="raw-input"]' ) . value
85+ const clearFlag = this . form . querySelector ( '[name="clear"]' )
86+ const type = this . formatSelect . value
8787 const layerId = this . layerSelect [ this . layerSelect . selectedIndex ] . value
8888 let layer
8989 if ( type === 'umap' ) {
9090 this . map . once ( 'postsync' , this . map . _setDefaultCenter )
9191 }
9292 if ( layerId ) layer = this . map . datalayers [ layerId ]
93- if ( layer && this . clearFlag . checked ) layer . empty ( )
93+ if ( layer && clearFlag . checked ) layer . empty ( )
9494 if ( this . fileInput . files . length ) {
9595 for ( const file of this . fileInput . files ) {
9696 this . map . processFileToImport ( file , layer , type )
@@ -101,17 +101,17 @@ L.U.Importer = L.Class.extend({
101101 content : L . _ ( 'Please choose a format' ) ,
102102 level : 'error' ,
103103 } )
104- if ( this . rawInput . value && type === 'umap' ) {
104+ if ( rawInputValue && type === 'umap' ) {
105105 try {
106- this . map . importRaw ( this . rawInput . value , type )
106+ this . map . importRaw ( rawInputValue , type )
107107 } catch ( e ) {
108108 this . ui . alert ( { content : L . _ ( 'Invalid umap data' ) , level : 'error' } )
109109 console . error ( e )
110110 }
111111 } else {
112112 if ( ! layer ) layer = this . map . createDataLayer ( )
113- if ( this . rawInput . value ) layer . importRaw ( this . rawInput . value , type )
114- else if ( this . urlInput . value ) layer . importFromUrl ( this . urlInput . value , type )
113+ if ( rawInputValue ) layer . importRaw ( rawInputValue , type )
114+ else if ( urlInputValue ) layer . importFromUrl ( urlInputValue , type )
115115 else if ( this . presetSelect . selectedIndex > 0 )
116116 layer . importFromUrl (
117117 this . presetSelect [ this . presetSelect . selectedIndex ] . value ,
0 commit comments