0

I am working on an application using map on WP8 and I have to know when does the map stop scrolling so I can send my asynchronous requests to the webservice to get my data.

The only event handler I found which could correspond is ViewChanged but the problem is that it is called while the map is still moving, and I only want to send requests to my server when the user stops scrolling where he wants.

Has anyone encountered this problem and found a solution to it ?

Thank you

A.K.
  • 3,321
  • 1
  • 15
  • 27
Wawa08
  • 168
  • 2
  • 12

1 Answers1

2

It should be fired only when the map has stopped changing that's why you have two different events: ViewChanging and ViewChanged.

See Maps events on the MSDN:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.maps.controls.map_events(v=vs.105).aspx

Additionnaly, you can also use CenterChanged and ZoomLevelChanged that should be fired when the view has been updated.

  • CenterChanged:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.maps.controls.map.centerchanged(v=vs.105).aspx

  • ViewChanged:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.maps.controls.map.zoomlevelchanged(v=vs.105).aspx

Nicolas Boonaert
  • 2,954
  • 1
  • 20
  • 28
  • Thank you but actually viewChanged is called many times when the map is scrolling, it just means that the view changed, not that the map stopped to scroll. Any suggestion ? – Wawa08 Mar 12 '14 at 09:58
  • Try with CenterChanged, it should be fired only when the map has stopped moving. Another way would be to throttle the event and manage the calls with ViewChanging (if Changing is on, then wait 300 ms before calling the method) – Nicolas Boonaert Mar 12 '14 at 14:19
  • 1
    I used a timer combined to CenterChanged as you said thank you. For help with timer, this question may help others who encounter the same problem than me : http://stackoverflow.com/questions/12535722/what-is-the-best-way-to-implement-a-timer – Wawa08 Mar 17 '14 at 13:14