# Intercepting TrackOverlay VertexAdding Vertex

**URL:** <https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787>\
**Category:** WPF\
**Created:** [March 2, 2015, 3:00pm UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787 "2015-03-02T15:00:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/f08c70/32.png) [@Brandon](https://community.thinkgeo.com/u/Brandon)\
**Post date:** [March 2, 2015, 3:00pm UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/1 "2015-03-02T15:00:10Z")

</div>

I&nbsp;created&nbsp;a&nbsp;new&nbsp;class&nbsp;that&nbsp;inherits&nbsp;from&nbsp;_TrackInteractiveOverlay_.&nbsp;&nbsp;I&nbsp;am&nbsp;using&nbsp;this&nbsp;class&nbsp;to&nbsp;implement&nbsp;snapping&nbsp;already,&nbsp;but&nbsp;I&nbsp;am&nbsp;looking&nbsp;to&nbsp;expand&nbsp;it&nbsp;to&nbsp;enforce&nbsp;some&nbsp;rules&nbsp;for&nbsp;the&nbsp;feature&nbsp;shape.&nbsp;&nbsp;Basically,&nbsp;as&nbsp;the&nbsp;feature&nbsp;draws,&nbsp;I&nbsp;am&nbsp;running&nbsp;the&nbsp;vertices&nbsp;through&nbsp;a&nbsp;function&nbsp;that&nbsp;will&nbsp;check&nbsp;to&nbsp;see&nbsp;if&nbsp;the&nbsp;line&nbsp;or&nbsp;polygon&nbsp;will&nbsp;self-intersect.&nbsp;&nbsp;  
  
  
  
My&nbsp;goal&nbsp;is&nbsp;to&nbsp;handle&nbsp;the&nbsp;_VertexAdding&nbsp;_event&nbsp;of&nbsp;the&nbsp;overlay&nbsp;so&nbsp;that&nbsp;I&nbsp;can&nbsp;reject&nbsp;new&nbsp;vertices&nbsp;that&nbsp;will&nbsp;create&nbsp;a&nbsp;bad&nbsp;feature.&nbsp;&nbsp;The&nbsp;_VertexAddingTrackInteractiveOverlayEventArgs&nbsp;_contains&nbsp;a&nbsp;_.Cancel_&nbsp;boolean.&nbsp;&nbsp;Your&nbsp;documentation&nbsp;isn’t&nbsp;really&nbsp;clear&nbsp;if&nbsp;this&nbsp;operates&nbsp;as&nbsp;a&nbsp;‘cancel&nbsp;adding’&nbsp;operation.&nbsp;&nbsp;I&nbsp;tried&nbsp;using&nbsp;it&nbsp;like..

> `If`&nbsp;`CheckForBadGeometry() ``Then`  
> `e.Cancel = ``True`  
> `End`&nbsp;`If`

  
Thinking&nbsp;that&nbsp;it&nbsp;would&nbsp;cancel&nbsp;the&nbsp;vertex&nbsp;adding.&nbsp;&nbsp;However,&nbsp;it&nbsp;saves&nbsp;the&nbsp;one&nbsp;vertex&nbsp;I&nbsp;add,&nbsp;and&nbsp;then&nbsp;on&nbsp;the&nbsp;2nd&nbsp;time&nbsp;it&nbsp;is&nbsp;triggered,&nbsp;it&nbsp;stops&nbsp;drawing&nbsp;completely.&nbsp;&nbsp;The&nbsp;map&nbsp;click&nbsp;handler&nbsp;still&nbsp;directs&nbsp;to&nbsp;adding&nbsp;a&nbsp;new&nbsp;vertex,&nbsp;but&nbsp;the&nbsp;track&nbsp;shape&nbsp;is&nbsp;gone.  
  
  
  
So,&nbsp;my&nbsp;main&nbsp;question&nbsp;is&nbsp;if&nbsp;this&nbsp;is&nbsp;a&nbsp;bug,&nbsp;or&nbsp;is&nbsp;there&nbsp;a&nbsp;better&nbsp;way&nbsp;to&nbsp;stop&nbsp;a&nbsp;vertex&nbsp;from&nbsp;being&nbsp;added.&nbsp;&nbsp;I&nbsp;don’t&nbsp;want&nbsp;to&nbsp;do&nbsp;it&nbsp;after&nbsp;the&nbsp;fact&nbsp;with&nbsp;the&nbsp;created&nbsp;shape.&nbsp;&nbsp;I&nbsp;would&nbsp;much&nbsp;rather&nbsp;stop&nbsp;the&nbsp;vertex&nbsp;being&nbsp;added&nbsp;than&nbsp;try&nbsp;to&nbsp;correct&nbsp;something&nbsp;down&nbsp;the&nbsp;line.  
  
  
  
Thanks&nbsp;for&nbsp;any&nbsp;info.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [March 3, 2015, 12:30am UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/2 "2015-03-03T00:30:18Z")

</div>

Hi&nbsp;Brandon,

I&nbsp;can’t&nbsp;reproduce&nbsp;your&nbsp;issue,&nbsp;so&nbsp;I&nbsp;recreate&nbsp;a&nbsp;project&nbsp;for  
your&nbsp;issue&nbsp;as&nbsp;the&nbsp;attachment.&nbsp;I&nbsp;think&nbsp;it&nbsp;may&nbsp;be&nbsp;caused&nbsp;by&nbsp;setting&nbsp;TrackMode,  
“TrackOverlay.TrackMode&nbsp;=&nbsp;TrackMode.Point”&nbsp;should&nbsp;be&nbsp;set.  
  
  
  
Thanks,

[post12496.zip](https://community.thinkgeo.com/uploads/default/original/2X/6/651afa23dbd3fdf674fec8782ae3f3e22a4c66dd.zip) (9.08 KB)

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [March 3, 2015, 2:30am UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/3 "2015-03-03T02:30:05Z")

</div>

Hi&nbsp;Brandon,  
  
  
  
Thanks&nbsp;a&nbsp;lot.&nbsp;It&nbsp;proved&nbsp;that&nbsp;there&nbsp;is&nbsp;a&nbsp;bug.&nbsp;We’ve&nbsp;fixed&nbsp;it&nbsp;in&nbsp;the&nbsp;latest&nbsp;build.&nbsp;Would&nbsp;you&nbsp;please&nbsp;get&nbsp;todays&nbsp;package&nbsp;(8.0.0.266&nbsp;or&nbsp;8.0.266.0)&nbsp;or&nbsp;higher&nbsp;version&nbsp;and&nbsp;have&nbsp;a&nbsp;try?  
  
  
  
Hope&nbsp;this&nbsp;is&nbsp;helpful&nbsp;and&nbsp;if&nbsp;the&nbsp;issue&nbsp;still&nbsp;persist,&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know.  
  
  
  
Regards&nbsp;and&nbsp;thanks,  
  
Troy

---

<div class="post-metadata">

**Author:** ![Lars\_Horsholt](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/a9adbd/32.png) [@Lars\_Horsholt](https://community.thinkgeo.com/u/Lars_Horsholt)\
**Post date:** [August 17, 2015, 5:25pm UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/4 "2015-08-17T17:25:41Z")

</div>

The&nbsp;new&nbsp;build&nbsp;solved&nbsp;the&nbsp;problem.&nbsp;-&nbsp;I&nbsp;have&nbsp;just&nbsp;had&nbsp;the&nbsp;same&nbsp;problem.&nbsp;Thanks&nbsp;for&nbsp;quick&nbsp;bug&nbsp;fixing.  
  
  
  
My&nbsp;goal&nbsp;is&nbsp;to&nbsp;handle&nbsp;the&nbsp;_VertexAdding&nbsp;_event&nbsp;of&nbsp;the&nbsp;overlay&nbsp;so&nbsp;that&nbsp;I&nbsp;can&nbsp;reject&nbsp;new&nbsp;vertices&nbsp;that&nbsp;will&nbsp;create&nbsp;a&nbsp;bad&nbsp;feature.&nbsp;It&nbsp;works&nbsp;nicely.&nbsp;BUT&nbsp;it&nbsp;does&nbsp;not&nbsp;handle&nbsp;the&nbsp;closing&nbsp;vertex&nbsp;(when&nbsp;I&nbsp;doubleclick).&nbsp;That&nbsp;is&nbsp;_VertexAdding_&nbsp;is&nbsp;not&nbsp;fired&nbsp;for&nbsp;the&nbsp;closing&nbsp;vertex.&nbsp;-&nbsp;Is&nbsp;that&nbsp;a&nbsp;bug?&nbsp;And&nbsp;if&nbsp;not,&nbsp;how&nbsp;do&nbsp;I&nbsp;reject&nbsp;the&nbsp;closing&nbsp;vertex?  
  
  
  
Best&nbsp;regards  
  
Lars

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [August 18, 2015, 4:17am UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/5 "2015-08-18T04:17:06Z")

</div>

Hi&nbsp;Lars,  
  
  
  
We&nbsp;looked&nbsp;into&nbsp;it&nbsp;and&nbsp;found&nbsp;the&nbsp;double&nbsp;click&nbsp;will&nbsp;go&nbsp;into&nbsp;another&nbsp;branch&nbsp;and&nbsp;won’t&nbsp;fire&nbsp;the&nbsp;VertexAdding&nbsp;event.&nbsp;Currently,&nbsp;I&nbsp;think&nbsp;it&nbsp;is&nbsp;hard&nbsp;to&nbsp;find&nbsp;a&nbsp;way&nbsp;to&nbsp;cancel&nbsp;the&nbsp;last&nbsp;vertex&nbsp;and&nbsp;we&nbsp;will&nbsp;keep&nbsp;looking&nbsp;on&nbsp;it&nbsp;to&nbsp;see&nbsp;if&nbsp;any&nbsp;approaches.&nbsp;&nbsp;For&nbsp;now,I&nbsp;guess&nbsp;a&nbsp;workaround&nbsp;is&nbsp;we&nbsp;cancel&nbsp;the&nbsp;whole&nbsp;feature&nbsp;by&nbsp;using&nbsp;TrackingEnding&nbsp;event&nbsp;or&nbsp;we&nbsp;can&nbsp;register&nbsp;the&nbsp;MouseMoved&nbsp;event&nbsp;to&nbsp;check&nbsp;every&nbsp;vertex&nbsp;and&nbsp;if&nbsp;the&nbsp;vertex&nbsp;is&nbsp;beyond,&nbsp;then&nbsp;give&nbsp;it&nbsp;an&nbsp;alert.&nbsp;  
  
  
  
Anyway,&nbsp;we&nbsp;will&nbsp;keep&nbsp;looking&nbsp;for&nbsp;an&nbsp;approach.  
  
Thanks,  
  
Troy

---

<div class="post-metadata">

**Author:** ![Lars\_Horsholt](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/a9adbd/32.png) [@Lars\_Horsholt](https://community.thinkgeo.com/u/Lars_Horsholt)\
**Post date:** [August 18, 2015, 5:41am UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/6 "2015-08-18T05:41:59Z")

</div>

Hi&nbsp;Troy&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;quick&nbsp;reply.&nbsp;I&nbsp;think&nbsp;I&nbsp;will&nbsp;go&nbsp;with&nbsp;your&nbsp;advice&nbsp;and&nbsp;use&nbsp;the&nbsp;TrackEnding&nbsp;event,&nbsp;and&nbsp;cancel&nbsp;the&nbsp;hole&nbsp;tracked&nbsp;feature.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards&nbsp;  
&nbsp;Lars

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [August 18, 2015, 8:08pm UTC](https://community.thinkgeo.com/t/intercepting-trackoverlay-vertexadding-vertex/3787/7 "2015-08-18T20:08:20Z")

</div>

Lars,&nbsp;  
&nbsp;&nbsp;  
&nbsp;You’re&nbsp;welcome.&nbsp;Please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;if&nbsp;any&nbsp;other&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Troy
