angular-google-maps updating marker model

泪湿孤枕 提交于 2019-12-04 19:23:47

you need to set modelsbyref to false in ui-gmap-markers directives

 <ui-gmap-markers models="places" coords="'self'" modelsbyref="false">  

   </ui-gmap-markers>

Same happened with me. Spent hours to find solutions.

It seemed like whenever we update markers angularjs doesn't update it immediately. just call $scope.$digest() after pushing new marker to the array.

Also check $scope.$apply() function, it calls $scope.$digest() automatically. Please refer to this tutorial which explain in detail: tutorial showing $scope.$digest(), $scope.$apply, $scope.watch

Its written in above tutorial:

You may encounter some corner cases where AngularJS does not call the $digest() function for you. You will usually detect that by noticing that the data bindings do not upate the displayed values. In that case, call $scope.$digest() and it should work. Or, you can perhaps use $scope.$apply()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!