Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 谷歌地图LatLong选择器-LatLong在1个字段中_Jquery_Wordpress_Google Maps_Maps - Fatal编程技术网

Jquery 谷歌地图LatLong选择器-LatLong在1个字段中

Jquery 谷歌地图LatLong选择器-LatLong在1个字段中,jquery,wordpress,google-maps,maps,Jquery,Wordpress,Google Maps,Maps,我有一个关于用于自定义Wordpress短代码的jQuery插件的问题。 该插件是谷歌地图的搜索表单,以LatLong作为输出 链接到插件: 我使用的示例代码来自:“可编辑和可选择的纬度/经度值” 纬度和经度都作为隐藏输入输出。 我希望在1个隐藏输入中输出纬度和经度 示例输出: <input type="text" class="gllpLatitude" value="52.372086"> <input type="text" class="gllpLongitude" v

我有一个关于用于自定义Wordpress短代码的jQuery插件的问题。 该插件是谷歌地图的搜索表单,以LatLong作为输出

链接到插件: 我使用的示例代码来自:“可编辑和可选择的纬度/经度值”

纬度和经度都作为隐藏输入输出。 我希望在1个隐藏输入中输出纬度和经度

示例输出:

<input type="text" class="gllpLatitude" value="52.372086">
<input type="text" class="gllpLongitude" value="4.898437">

期望输出:

<input type="text" class="LatLong" value="52.372086,4.898437">

问题是:怎么做


以下是插件的代码:

您可以为此添加另一个隐藏字段。由于每当移动标记时都会触发
location\u changed
事件,因此您可以轻松地更新此值。您还需要在初始化时设置此值,因此如果用户提交from而不更改标记位置,latLng值仍将正确设置

$(document).bind("location_changed", function(event, object) {
    updateLatLng($(this));
});

$(".gllpLatlonPicker").each(function() {
    (new GMapsLatLonPicker()).init( $(this) );
    updateLatLng($(this));
});

function updateLatLng(object) {
    var lat = $(object).find('.gllpLatitude').val();
    var lng = $(object).find('.gllpLongitude').val();
    var latLng = lat + ',' + lng;
    $(object).find('.gllpLatLong').val(latLng);
}

工作小提琴

您可以为此添加另一个隐藏字段。由于每当移动标记时都会触发
location\u changed
事件,因此您可以轻松地更新此值。您还需要在初始化时设置此值,因此如果用户提交from而不更改标记位置,latLng值仍将正确设置

$(document).bind("location_changed", function(event, object) {
    updateLatLng($(this));
});

$(".gllpLatlonPicker").each(function() {
    (new GMapsLatLonPicker()).init( $(this) );
    updateLatLng($(this));
});

function updateLatLng(object) {
    var lat = $(object).find('.gllpLatitude').val();
    var lng = $(object).find('.gllpLongitude').val();
    var latLng = lat + ',' + lng;
    $(object).find('.gllpLatLong').val(latLng);
}
工作小提琴