I want to alert the selected location but it is not alerting anything:
<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');
});
You need to put the code of placeChanged within you placepicker initialization
like this
var mapPlacepicker = $(".placepicker").placepicker({placeChanged: function(place) {
alert("place changed: "+ place.formatted_address +" Latitude" +this.getLocation().latitude + " Longitude" + this.getLocation().longitude);
}});
here is a jsfiddle https://jsfiddle.net/vfgv7dtz/5/