最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Logicify jQuery Location Picker Plugin - Programatically Setting Location - Stack Overflow

programmeradmin1浏览0评论

This is dealing with Logicify's Location Picker plugin for jQuery, I'm having an issue attempting to programmatically set the map location.

This questions has been asked a few times without an answer: Logicify Location picker using dynamic change for input

Essentially I would assume that I could programmatically set the values of latitude and/or longitude and the plugin would respond as if I had typed those values in (through the inputBinding latitude and longitude 'on('change' functions). However it doesn't.

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')
    },
    enableAutoplete: true
});

If I type in the value it will change, however if I use something like:

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

I've tried various attempts at calling .locationpicker() after resetting the values or .trigger() on the values themselves. I'm not sure how to proceed if I can't get the inputBindings within the plugin to fire.

Can anyone steer me in a direction to get the inputBinding functions to pick up on programmatically setting the lat and long?

I'm hoping that I haven't mitted a faux pas here rehashing a question that has not been answered.

This is dealing with Logicify's Location Picker plugin for jQuery, I'm having an issue attempting to programmatically set the map location.

This questions has been asked a few times without an answer: Logicify Location picker using dynamic change for input https://github./Logicify/jquery-locationpicker-plugin/issues/20

Essentially I would assume that I could programmatically set the values of latitude and/or longitude and the plugin would respond as if I had typed those values in (through the inputBinding latitude and longitude 'on('change' functions). However it doesn't.

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')
    },
    enableAutoplete: true
});

If I type in the value it will change, however if I use something like:

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

I've tried various attempts at calling .locationpicker() after resetting the values or .trigger() on the values themselves. I'm not sure how to proceed if I can't get the inputBindings within the plugin to fire.

Can anyone steer me in a direction to get the inputBinding functions to pick up on programmatically setting the lat and long?

I'm hoping that I haven't mitted a faux pas here rehashing a question that has not been answered.

Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Dec 7, 2015 at 15:52 ashcanschoolashcanschool 3273 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Try

$('#map').locationpicker("location", {latitude: 55.859028119431926, longitude: -4.234895706176758});
发布评论

评论列表(0)

  1. 暂无评论