javascript - Google maps polygon not updating color after setOptions? -
i'm using google maps api alongside angularjs. have following function change polygon's color using setoptions
:
desk.modcolor = function (color) { desk.setoptions({ fillcolor: color }); }
i'm calling within angularjs code following:
$scope.focuseddesk.modcolor('#0592fa');
however, working 75% of time. after enough scope manipulation in angularjs, stops working. if console.log
desk
object after modcolor
call, has correct fillcolor
, polygon on map hasn't updated visually.
any ideas why happening? there way ensure setoptions
updates map/polygon visually? thanks.
condition 1
if manipulating dom in form within angularjs should use directives in case should write directive you:
angular.module('mymodule',[]) .directive('mydirective',function(){ return { scope: { focuseddesk:'=' }, link: function(scope, ielement, iattrs){ scope.$watch('your-whatever-object-or-property-you-want-to-watch-over', function(){ //your desired action }) } } })
and usage this:
<div my-directive focuseddesk='focuseddesk'></div>
condition 2
if concerned property's value $scope.$watch
same above in controller
function
Comments
Post a Comment