1

I use this:ngmap.github.io and ionic framework.

I try get current position daynamicly like this js code:

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

});

how can I convert this code to angularjs?

partiz
  • 1,206
  • 2
  • 13
  • 34

1 Answers1

1

According to the documentation:

NgMap.getMap().then(function(map) {...}) is used to to get a map instance.

Example

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>
Vadim Gremyachev
  • 57,952
  • 20
  • 129
  • 193