場所をマッピングし、その住所を入力フィールドに入力して、マーカーを追加したいと思います。
現在私はこれを持っています、それはうまくいきます:
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");
} });
誰かが私が間違っていることを教えてもらえますか?