[問題] 關於 google map v3 api的 dragend問題

看板Ajax作者 (Rick)時間11年前 (2015/06/13 13:58), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
想請問大家關於 google map v3 api的 dragend傾聽事件內透過Geocoder() API的座標位 置取得formatted_address的住址字串,然後要傳回給輸入欄位。 現在重點是當我移動Marker時,我無法把住址字串傳回給輸入欄位。 目前是有透過$watch來監聽.....但是一樣沒辦法把住址傳回給輸入欄位。 有透過console.log()來觀察,是有變化的。 我是用 IONIC Framework 手機排版...不好意思... 謝謝大家 ><" 這是在view內 <div class="list list-inset"> <label class="item item-input"> <input type="text" placeholder="Pickup location" ng-model-options="{ updateOn :'default blur' }" ng-model="pickupLocation" ng-blur="pickupLocationEvent(pick upLocation)" /> </label> </div> ---------------------------------------------- 這是在controller內 google.maps.event.addListener(pickupLocationMarker, 'dragend', function(evt){ console.log("lat : "+evt.latLng.lat().toFixed(6)+"\nlng : "+evt.latLng.lng().toFixed(6)); var myLatlng = new google.maps.LatLng(evt.latLng.lat(), ev t.latLng.lng()); geocoder.geocode({'latLng': myLatlng}, function(results, s tatus) { if (status == google.maps.GeocoderStatus.OK) { if(results[1]) { dragedAddress = results[1].formatted_address; infowindow.setContent(dragedAddress); infowindow.open(map, pickupLocationMarker); //$scope.pickupLocationAddress = dragedAddress; $scope.$watch(function () { $scope.pickupLocation = dragedAddress; console.log($scope.pickupLocation) }); } else { alert('No results found'); } } else { alert('Geocoder failed due to: ' + status); } }); }); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.164.9.117 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1434175118.A.359.html
文章代碼(AID): #1LUyQEDP (Ajax)
文章代碼(AID): #1LUyQEDP (Ajax)