angularjs-google-maps icon indicating copy to clipboard operation
angularjs-google-maps copied to clipboard

blinking icons on position update

Open rmjoia opened this issue 12 years ago • 10 comments

I don't know if anyone has this experience so this is more like a question, than an issue.

I have a interval in angular that is requesting the positions to the API, on every update, the icons blink or flicker.. any suggestions?

regards, Ricardo

rmjoia avatar Oct 23 '14 11:10 rmjoia

Thanks for using this and reporting it.

If you maintain markers using ng-repeat, the markers will flick because ng-repeat will re-create html elements, and the marker are synced to them.

That means when you update scope variable that are used in ng-repeat, the tag will be removed and will be added again even though they are the same. The actual markers will be also removed and added again even thought they are the same.

If you want to avoid this,

  1. You can maintain markers manually without using ng-repeat like this example
  2. Or, you can change the code not to remove it when they are the same, and send me a pull request.

Allen

allenhwkim avatar Oct 23 '14 13:10 allenhwkim

Hi Allen, Thanks for the support.

I'm not using ng-repeat, because when I first tried it, it left a trace when changing position so I used the other example of yours of dynamic markers, I'll have to analyse your suggestion closer.

Thank you so much. Ricardo

rmjoia avatar Oct 23 '14 14:10 rmjoia

FYI, for your information, ng-repeat does not leave a trace of previous marker any more. I have made a fix for that.

If you simplify your problem and can create a single page example, I will be glad to help with it.

allenhwkim avatar Oct 23 '14 14:10 allenhwkim

@rmjoia when you have icons that represent something that changes its position all the time, make sure you use the "trackBy" statement in the ngRepeat to prevent DOM insertion/deletion when you refresh the markers, thus preventing the flash.

michaelwsk avatar Oct 23 '14 22:10 michaelwsk

@michaelwsk, I did not know track by can control DOM re-creation. It's good to learn from the community. @rmjoia did say that he does not use ng-repeat though. He might have some other issues which I do not know.

allenhwkim avatar Oct 23 '14 22:10 allenhwkim

@michaelwsk thanks, I'm not using ng-repeat because it had that issue that @allenhwkim told it's been solved, yet, the trail of the positions was a nice feature to implement, because it could be used to track something in real time with tail.

I'll be revising all of that soon to optimize the app, @michaelwsk can you provide-me some reference of the "trackBy" statement, example or something so I can study it? Thanks in advance.

@allenhwkim I know that, to use the google maps api you have to create an app id and all, and that's limited to a number of hits, I did not find any "simple" way to change that, are we using your id? shouldn't it be something that anyone should use their own? Is this wrong?

thank you both. Ricardo

rmjoia avatar Oct 24 '14 08:10 rmjoia

@rmjoia, I think you are talking about api key and usage limit.

As mentioned on the google page, I don't generate that much large volume of hits although I wish, so I do not worry about api key at this time.

Adding api key is as simple as adding another query string.

<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>

allenhwkim avatar Oct 24 '14 14:10 allenhwkim

@rmjoia look for ng repeat's documentation on repeat_expression for more information on track by.

michaelwsk avatar Oct 27 '14 04:10 michaelwsk

Closing, @rmjoia if you still did not solve the problem, please re-open it with an example in plnkr.

allenhwkim avatar Oct 27 '14 15:10 allenhwkim

trackBy resolved my flickering problem as well.

josephmiclaus avatar Sep 02 '15 13:09 josephmiclaus