2015-12-07 87 views
0

這是針對jQuery的Logicify的位置選取器插件,我有一個嘗試以編程方式設置地圖位置的問題。Logicify jQuery位置選取器插件 - 以編程方式設置位置

這個問題已經被問了幾次沒有答案: Logicify Location picker using dynamic change for input https://github.com/Logicify/jquery-locationpicker-plugin/issues/20

基本上我會以爲我可以編程設置緯度和/或經度的價值觀和我彷彿插件會作何反應鍵入的(這些值通過inputBinding緯度和 'ON(' 變更」功能經度),但它沒有。

HTML

<label for="lat">Latitude</label> 
<input name="lat" id="lat" value="56.47073634828131" /> 

<label for="long">Longitude</label> 
<input name="long" id="long" value="-2.982454299926758" /> 

<input type="hidden" id="address" /> 
<input type="hidden" id="radius" /> 

<div id="map" style="height: 250px;"></div> 

JS

$('#map').locationpicker({ 
    location: {latitude: $('#lat').val(), longitude: $('#long').val()}, 
    radius: 0, 
    zoom: 9, 
    inputBinding: { 
     latitudeInput: $('#lat'), 
     longitudeInput: $('#long') 
    }, 
    enableAutocomplete: true 
}); 

如果我在它會改變的值類型,但是如果我使用類似:

$('#lat').val('55.859028119431926'); 
$('#long').val('-4.234895706176758'); 

我已經試過各種嘗試在呼叫.locationpicker()重置值後或.trigger()的值本身。如果我無法獲取插件中的inputBindings來觸發,我不知道如何繼續。

任何人都可以引導我在一個方向上獲取inputBinding函數來以編程方式設置lat和long嗎?

我希望我沒有在這裏犯過一個錯誤,重新提出一個沒有得到回答的問題。

回答

8

嘗試

$('#map').locationpicker("location", {latitude: 55.859028119431926, longitude: -4.234895706176758}); 
相關問題