我想提醒所选位置,但它没有提醒任何事情:
<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');
});
答案 0 :(得分:1)
您需要将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/