dylanfprice / angular-gm

AngularJS Google Maps Directives
MIT License
198 stars 47 forks source link

Do center and bounds of the map correlate? #47

Closed drunkhacker closed 10 years ago

drunkhacker commented 10 years ago

I think it seems not actually.

in the source code,

  if (hasCenter) {
    scope.$watch('gmCenter', function (newValue, oldValue) {
      var changed = (newValue !== oldValue);
      if (changed && !controller.dragging) {
        var latLng = newValue;
        if (latLng)
          controller.center = latLng;
      }
    }, true);
  }

and here,

  if (hasBounds) {
    scope.$watch('gmBounds', function(newValue, oldValue) {
      var changed = (newValue !== oldValue);
      if (changed && !controller.dragging) {
        var bounds = newValue;
        if (bounds)
          controller.bounds = bounds; 
      }
    });
  }

Both of $watch expression doesn't update the other side simultaneously. But it is quite natural that if one of them changes, the other also does.

What do you think?

drunkhacker commented 10 years ago

Sorry. They do. After set center from my controller, AngularGM updates controller's center. Then it calls updateScope which handles other properties as well.