2

I am working on an application and need to convert an address supplied by user to lat lng and update a google map. I am using angular js version 1.0.0 Problem is in firefox i keep getting a too much recursion error.

app.controller("BasicMapController", function($scope, $timeout){
.......
angular.extend($scope, {
.......
checking_address: false// curently trying to get lat long from address
});
......

I had to create an ngBlur directive since 1.0.0 didn't have it and upgrading is not an option since too much other code breaks.

app.directive('ngBlur', function() {
return function( scope, elem, attrs ) {
elem.bind('blur', function() {
scope.$apply(attrs.ngBlur);
});
};

});

On my page i add ng-blur="onblur_()" to the relevant text area and then in my controller i define the relevant function:

$scope.onblur_ = function ($event) {
    if ($scope.checking_address)
        return;
    var map_scope = angular.element($('.google-map')).scope();
    var address = document.getElementById("id_address").value;
    if ( !! !address)
        return;
    $scope.checking_address = true;
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({
        'address': address
    }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            map_scope.map._instance.panTo(results[0].geometry.location);
            if ($scope.markers[0] == undefined) {
                $scope.markers[0] = new google.maps.Marker({
                    map: map_scope.map._instance,
                    position: results[0].geometry.location
                });
            } else
                $scope.markers[0].setPosition(results[0].geometry.location);
        }
        $scope.checking_address = false;
    });
}

The code works fine in Opera and Chromium. Any ideas on what could be wrong or how i could get around the problem?

Pointy
  • 405,095
  • 59
  • 585
  • 614
lenny
  • 231
  • 1
  • 3
  • 11
  • Well, there have been a *lot* of bug fixes in Angular since 1.0.0 (almost 2 years old) – Pointy Feb 17 '14 at 15:54
  • possible duplicate of [Maximum call stack size exceeded / Too much recursion on Google maps API custom map type with allowed bounds](http://stackoverflow.com/questions/22434779/maximum-call-stack-size-exceeded-too-much-recursion-on-google-maps-api-custom) – Paul Sweatte Dec 31 '14 at 18:56

0 Answers0