Angularjs在功能中显示数据

时间:2017-01-19 07:56:58

标签: angularjs

我使用以下代码获取NorthEast坐标。但是如何在标记功能中显示此lat0坐标。你能救我吗?



google.maps.event.addListener($scope.map, 'idle', function(event){
			var lat0 = $scope.map.getBounds().getNorthEast().lat();
			var lng0 = $scope.map.getBounds().getNorthEast().lng();
			var lat1 = $scope.map.getBounds().getSouthWest().lat();
			var lng1 = $scope.map.getBounds().getSouthWest().lng();
			});
			




这很好但是如何在标记功能中显示lat0



var createMarker = function (info) {
	
        var marker = new google.maps.Marker({
            map: $scope.map,
            position: new google.maps.LatLng(info.lat, info.lng),
            title: info.prop_Name,
			animation: google.maps.Animation.DROP,
			lat0 : **lat0** ?? notworking ??
        });
  }




注意:info.lat0无效

1 个答案:

答案 0 :(得分:2)

变量不会随着摘要周期而更新。

在您的示波器上使用apply,效果很好。

google.maps.event.addListener($scope.map, 'idle', function
    $scope.test = $scope.map.getBounds().getNorthEast().lat();
    $scope.$apply();
});

模板:

Lat0: {{test}}

我刚做了测试,我让你随心所欲地使用它。