# User Click to select road (how)

**URL:** <https://community.thinkgeo.com/t/user-click-to-select-road-how/357>\
**Category:** WinForms\
**Created:** [April 15, 2009, 4:02pm UTC](https://community.thinkgeo.com/t/user-click-to-select-road-how/357 "2009-04-15T16:02:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth\_langley](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f9ae1b/32.png) [@kenneth\_langley](https://community.thinkgeo.com/u/kenneth_langley)\
**Post date:** [April 15, 2009, 4:02pm UTC](https://community.thinkgeo.com/t/user-click-to-select-road-how/357/1 "2009-04-15T16:02:27Z")

</div>

I&nbsp;have&nbsp;a&nbsp;map&nbsp;with&nbsp;one&nbsp;layer,&nbsp;roads.&nbsp;How&nbsp;do&nbsp;I&nbsp;detect&nbsp;which&nbsp;road&nbsp;the&nbsp;user&nbsp;clicks&nbsp;on&nbsp;in&nbsp;the&nbsp;mapclick&nbsp;event&nbsp;?

---

<div class="post-metadata">

**Author:** ![Kimberly](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kimberly](https://community.thinkgeo.com/u/Kimberly)\
**Post date:** [April 15, 2009, 5:14pm UTC](https://community.thinkgeo.com/t/user-click-to-select-road-how/357/2 "2009-04-15T17:14:20Z")

</div>

I'll&nbsp;try&nbsp;to&nbsp;answer&nbsp;this,&nbsp;but&nbsp;it&nbsp;might&nbsp;depend&nbsp;on&nbsp;what&nbsp;kind&nbsp;of&nbsp;layer&nbsp;you&nbsp;have.&nbsp;In&nbsp;my&nbsp;example,&nbsp;I'm&nbsp;using&nbsp;an&nbsp;InMemoryFeatureLayer&nbsp;so&nbsp;this&nbsp;might&nbsp;be&nbsp;specific&nbsp;to&nbsp;this.&nbsp;First&nbsp;I&nbsp;find&nbsp;the&nbsp;layer&nbsp;using&nbsp;map.FindFeatureLayer,&nbsp;which&nbsp;I&nbsp;then&nbsp;cast&nbsp;as&nbsp;an&nbsp;InMemoryFeatureLayer.

Then&nbsp;my&nbsp;code&nbsp;looks&nbsp;something&nbsp;like&nbsp;this:  
  
&nbsp;

`if ((featureLayer as InMemoryFeatureLayer).InternalFeatures.Count > 0) { featureLayer.Open(); Collection<Feature> selectedfeatures = featureLayer.QueryTools.GetFeaturesNearestTo(pointShape, GeographyUnit.Meter, 1, ReturningColumnsType.AllColumns); featureLayer.Close(); if (selectedfeatures.Count > 0) {`

Then&nbsp;selectedFeatures&nbsp;is&nbsp;just&nbsp;a&nbsp;collection&nbsp;which&nbsp;I&nbsp;can&nbsp;use&nbsp;as&nbsp;needed.&nbsp;I&nbsp;will&nbsp;usually&nbsp;do&nbsp;a&nbsp;check&nbsp;on&nbsp;the&nbsp;distance&nbsp;between&nbsp;where&nbsp;the&nbsp;user&nbsp;clicked&nbsp;and&nbsp;the&nbsp;shape&nbsp;so&nbsp;if&nbsp;my&nbsp;only&nbsp;shapes&nbsp;are&nbsp;in&nbsp;Portland,&nbsp;but&nbsp;they&nbsp;click&nbsp;in&nbsp;NYC,&nbsp;they&nbsp;won't&nbsp;get&nbsp;a&nbsp;shape&nbsp;in&nbsp;Portland.

Hope&nbsp;this&nbsp;helps!

---

<div class="post-metadata">

**Author:** ![Kimberly](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kimberly](https://community.thinkgeo.com/u/Kimberly)\
**Post date:** [April 15, 2009, 5:22pm UTC](https://community.thinkgeo.com/t/user-click-to-select-road-how/357/3 "2009-04-15T17:22:11Z")

</div>

I&nbsp;should&nbsp;have&nbsp;included&nbsp;another&nbsp;line&nbsp;of&nbsp;code&nbsp;in&nbsp;my&nbsp;previous&nbsp;post.&nbsp;&nbsp;The&nbsp;pointShape&nbsp;that&nbsp;I&nbsp;refer&nbsp;to&nbsp;was&nbsp;taken&nbsp;from&nbsp;e.WorldLocation&nbsp;in&nbsp;the&nbsp;mapClick&nbsp;event.

Kimberly

---

<div class="post-metadata">

**Author:** ![Lee](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@Lee](https://community.thinkgeo.com/u/Lee)\
**Post date:** [April 17, 2009, 10:18am UTC](https://community.thinkgeo.com/t/user-click-to-select-road-how/357/4 "2009-04-17T10:18:46Z")

</div>

Kenneth,

Attachment&nbsp;is&nbsp;a&nbsp;sample&nbsp;to&nbsp;demonstrate&nbsp;how&nbsp;to&nbsp;select&nbsp;a&nbsp;feature&nbsp;by&nbsp;clicking&nbsp;on&nbsp;the&nbsp;map&nbsp;and&nbsp;delete&nbsp;it.&nbsp;Hope&nbsp;it&nbsp;helps.

Thanks,  
  
ThinkGeo&nbsp;Support

[608-DeleteFeatureDemo.zip](https://community.thinkgeo.com/uploads/default/original/2X/9/94393a81262015cb3e8ec6f1c9fbabf8367b8d87.zip) (11.4 KB)
