C#,Gmap.net :Generating exception while plotting 5 markers on google map using Gmap.net liabrary

前端 未结 1 1320
后悔当初
后悔当初 2021-01-27 00:08

i am using Gmap.net library to plot markers at a particular let-long coming after calculation made by triangulation algo on google maps,when i worked for two markers its works f

相关标签:
1条回答
  • 2021-01-27 00:25

    So you mentioned you run separate threads to add the markers and routes. This can result in threading issues. The UI thread tries to draw your markers and therefore iterates over the lists of markers. When another thread adds a marker to the collection of markers that are being currently drawn, then the iterator becomes invalid, hence the exception is thrown.

    The solution: Make sure the adding of the markers happens in an UI synchronized manner.

    As a simple first approach to validate the assumption above try your code without threading and then read how to synchronize your threads with the main thread. Basically the eventual AddMarker() has to happen on the main thread.

    Edit You'll need to apply synchronisation as demonstrated in this link with the help of InvokeRequired and BeginInvoke. Have a look how they update the text control, an uni element as the gmap instance. For this then to work the actual add of the markers has to happen within that action/delegate. Let's try to take it from there and let us know how far you get, please.

    0 讨论(0)
提交回复
热议问题