使用 ng-map 的当前边界形式 google 地图

current Bounds form google map with ng-map

我使用 this:ngmap.github.io 和离子框架。

我尝试像这个 js 代码那样每天获取当前位置:

google.maps.event.addListener(map, 'idle', function(){
    var bounds = map.getBounds();
 //returns an object with the NorthEast and SouthWest LatLng points of the bounds

});

如何将此代码转换为 angularjs?

根据the documentation

NgMap.getMap().then(function(map) {...})用于获取地图实例。

例子

var app = angular.module('myapp', ['ngMap']);
app.controller('mapcntrl', function (NgMap, $scope) {

    NgMap.getMap().then(function (map) {
        console.log(map.getBounds().toString());
    });
});
<script src="https://maps.google.com/maps/api/js"></script>
<script src="https://code.angularjs.org/1.3.15/angular.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<div ng-app="myapp" ng-controller="mapcntrl">
    <ng-map center="[-26.1367035,124.2706638]" zoom="5"></ng-map>
</div>