我想映射一個位置,將它的地址填充到輸入字段並添加一個標記。谷歌地圖V3 - 如何從gmap發射回調函數
目前我有這個,它的工作原理:
var home = new google.maps.LatLng(49.93547768118736, 11.2954580783844);
$('#map_canvas_1').gmap({'center': home, 'zoom':17 });
$('#map_canvas_1').gmap('addMarker', { 'position': home, 'animation' : google.maps.Animation.DROP });
$('#map_canvas_1').gmap('search', { 'location': home }, function (results, status) {
$('#to').val(results[0].formatted_address);
});
什麼我不知道是爲什麼我不能使用一個回調函數來填充輸入字段像這樣:
$('#map_canvas_1').gmap({'center': home, 'zoom':17, 'callback': function() {
$('#map_canvas_1').gmap('search', { 'location': home }, function (results, status) {
$('#to').val(results[0].formatted_address);
});
} });
作爲事事實上,甚至沒有這個作品:
$('#map_canvas_1').gmap({'center': home, 'zoom':17, 'callback': function() {
alert ("callback");
} });
有人可以告訴我我做錯了什麼?
好的。感謝您的鏈接! – frequent