2016-09-22 25 views
1

當應用程序調用手機的鍵盤(編輯文字時),地圖面板變換,如下圖所示: enter image description here 可能是什麼原因,我添加的地圖是這樣的:科爾多瓦:傳單地圖圖塊禁用轉換映射窗格

map = L.map('main').setView([9.123011560267038, 125.53513369515711], 15); 
    L.tileLayer('./tile/cbr_new_design_tms2/{z}/{x}/{y}.png', { 
     minZoom: 14, 
     maxZoom: 16, 
     tms: true 
    }).addTo(map); 

HTML:

<div class="panel" id="main" style="padding:0;overflow:hidden" data-title="Main"> 
       <header> 
        <h1>Main</h1> 
        <a href="#modal1" class="button big icon question" style="float:right;padding-top:0;outline:0" data-transition="up-reveal"></a> 
        <a href="#modal" class="button big icon settings" style="padding-top:0;outline:0" data-transition="up-reveal"></a> 
       </header> 

      </div> 

更新:我注意到,當鍵盤調用,小葉增加class="leaflet-map-pane" style="transform: translate3d(XXpx, XXpx, XXpx);"。它以某種方式轉換地圖窗格。那麼,如何防止傳單轉化呢?

+1

見https://stackoverflow.com/questions/38509121/leaflet-map-on-android-disrupted-by-appearance-of-keyboard – ghybs

+0

我使用科爾多瓦。 –

+0

您也可以使用Cordova自定義您的Android清單。看例如:https://stackoverflow.com/questions/12833145/how-to-properly-configure-phonegap-for-android-so-it-does-not-zoom-on-text-input/27145959#27145959和剛剛得到了與之相反的問題的人:https://stackoverflow.com/questions/39627268/android-webview-keyboard-covering-up-input – ghybs

回答

0

正如@ghybs指出的那樣,Cordova配置選項很有可能解決這個問題。

否則,如果您可以在用戶隱藏鍵盤時運行ome javascript代碼,請在地圖實例上調用invalidateSize()方法。

+0

我已經嘗試了你和@ghybs的建議,他們都沒有工作。 –

0

通過註釋leaflet-src.js解決了這個:

_onResize: function() { 
     L.Util.cancelAnimFrame(this._resizeRequest); 
     this._resizeRequest = L.Util.requestAnimFrame(
       function() { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container); 
    },