To represent a graphic moving along with mouse cursor, I am adding a point graphic on mouse move and clear it when mouse move is triggered at a new location and a graphic for new location. But the graphics never gets cleared. They stay on map. Here is the code snippet
<SPAN class="keyword token">private</SPAN> IDisposable PtGraphic<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">protected</SPAN> <SPAN class="keyword token">override</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnToolMouseMove</SPAN><SPAN class="punctuation token">(</SPAN>MapViewMouseEventArgs e<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> pt <SPAN class="operator token">=</SPAN> ActiveMapView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ClientToMap</SPAN><SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">.</SPAN>ClientPoint<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token function">ClearGraphic</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">ref</SPAN> PtGraphic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
PtGraphic <SPAN class="operator token">=</SPAN> <SPAN class="token function">AddGraphicToMap</SPAN><SPAN class="punctuation token">(</SPAN>pt<SPAN class="punctuation token">,</SPAN> ColorFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>RedRGB<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> SimpleMarkerStyle<SPAN class="punctuation token">.</SPAN>Circle<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">base</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">OnToolMouseMove</SPAN><SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">ClearGraphic</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">ref</SPAN> IDisposable graphic<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>graphic <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
graphic<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Dispose</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
graphic <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">async</SPAN> Task<SPAN class="operator token"><</SPAN>IDisposable<SPAN class="operator token">></SPAN> <SPAN class="token function">AddGraphicToMap</SPAN><SPAN class="punctuation token">(</SPAN>Geometry geom<SPAN class="punctuation token">,</SPAN> CIMColor color<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">double</SPAN> size <SPAN class="operator token">=</SPAN> <SPAN class="number token">1.0</SPAN><SPAN class="punctuation token">,</SPAN> SimpleMarkerStyle markerStyle <SPAN class="operator token">=</SPAN> SimpleMarkerStyle<SPAN class="punctuation token">.</SPAN>Rectangle<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">///Build Symbology</SPAN>
<SPAN class="keyword token">return</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddOverlay</SPAN><SPAN class="punctuation token">(</SPAN>geom<SPAN class="punctuation token">,</SPAN> symbol<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Am I missing something ?
Appreciate any help.