作者slamgundam (Rick)
看板Ajax
标题[问题] 关於 google map v3 api的 dragend问题
时间Sat Jun 13 13:58:35 2015
想请问大家关於 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://webptt.com/cn.aspx?n=bbs/Ajax/M.1434175118.A.359.html