我怎样才能得到当前的地点选择器位置?
How can I get the current placepicker location?
我想提醒所选位置,但它没有提醒任何东西:
<div class="form-group">
<input class="placepicker form-control" data-map-container-id="collapseOne"/>
</div>
<div id="collapseOne" class="collapse">
<div class="placepicker-map thumbnail"></div>
</div>
var mapPlacepicker = $(".placepicker").placepicker();
$(".placepicker").each(function() {
var target = this;
var $collapse = $(this).parents('.form-group').next('.collapse');
var $map = $collapse.find('.another-map-class');
var placepicker = $(this).placepicker({
map: $map.get(0),
placeChanged: function(place) {
alert("place changed: ", place.formatted_address, this.getLocation());
}
}).data('placepicker');
});
你需要把 placeChanged 的代码放在你的 placepicker 初始化中
像这样
var mapPlacepicker = $(".placepicker").placepicker({placeChanged: function(place) {
alert("place changed: "+ place.formatted_address +" Latitude" +this.getLocation().latitude + " Longitude" + this.getLocation().longitude);
}});
这是一个 jsfiddle https://jsfiddle.net/vfgv7dtz/5/
我想提醒所选位置,但它没有提醒任何东西:
<div class="form-group">
<input class="placepicker form-control" data-map-container-id="collapseOne"/>
</div>
<div id="collapseOne" class="collapse">
<div class="placepicker-map thumbnail"></div>
</div>
var mapPlacepicker = $(".placepicker").placepicker();
$(".placepicker").each(function() {
var target = this;
var $collapse = $(this).parents('.form-group').next('.collapse');
var $map = $collapse.find('.another-map-class');
var placepicker = $(this).placepicker({
map: $map.get(0),
placeChanged: function(place) {
alert("place changed: ", place.formatted_address, this.getLocation());
}
}).data('placepicker');
});
你需要把 placeChanged 的代码放在你的 placepicker 初始化中
像这样
var mapPlacepicker = $(".placepicker").placepicker({placeChanged: function(place) {
alert("place changed: "+ place.formatted_address +" Latitude" +this.getLocation().latitude + " Longitude" + this.getLocation().longitude);
}});
这是一个 jsfiddle https://jsfiddle.net/vfgv7dtz/5/