# Draw features to interact with existing ones

**URL:** <https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871>\
**Category:** WebForms\
**Created:** [June 26, 2009, 3:34am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871 "2009-06-26T03:34:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sebastien](https://community.thinkgeo.com/u/sebastien)\
**Post date:** [June 26, 2009, 3:34am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/1 "2009-06-26T03:34:14Z")

</div>

Hello

I&nbsp;developped&nbsp;the&nbsp;gis&nbsp;module&nbsp;to&nbsp;draw&nbsp;features&nbsp;with&nbsp;holes.&nbsp;basically&nbsp;each&nbsp;time&nbsp;the&nbsp;user&nbsp;draw&nbsp;a&nbsp;new&nbsp;feature&nbsp;i&nbsp;check&nbsp;:  
  
-&nbsp;if&nbsp;the&nbsp;new&nbsp;feature&nbsp;is&nbsp;inside&nbsp;an&nbsp;existing&nbsp;one&nbsp;I&nbsp;draw&nbsp;the&nbsp;difference&nbsp;between&nbsp;them  
  
-&nbsp;if&nbsp;the&nbsp;new&nbsp;feature&nbsp;contains&nbsp;an&nbsp;existing&nbsp;one&nbsp;I&nbsp;draw&nbsp;the&nbsp;difference&nbsp;between&nbsp;them  
  
-&nbsp;if&nbsp;the&nbsp;new&nbsp;feature&nbsp;intersects&nbsp;an&nbsp;existing&nbsp;one&nbsp;I&nbsp;draw&nbsp;the&nbsp;union&nbsp;between&nbsp;them  
  
  
  
  
  
I&nbsp;use&nbsp;some&nbsp;method&nbsp;provided&nbsp;by&nbsp;the&nbsp;core&nbsp;assembly  
  
BaseShape&nbsp;  
  
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;Contains(Feature&nbsp;targetFeature);  
  
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;IsWithin(Feature&nbsp;targetFeature);  
  
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;Intersects(Feature&nbsp;targetFeature);  
  
  
  
AreaBaseShape&nbsp;&nbsp;&nbsp;&nbsp;  
  
&nbsp;&nbsp;&nbsp;&nbsp;MultipolygonShape&nbsp;Union(Feature&nbsp;targetFeature);  
  
&nbsp;&nbsp;&nbsp;&nbsp;MultipolygonShape&nbsp;GetDifference(Feature&nbsp;targetFeature);  
  
&nbsp;&nbsp;&nbsp;&nbsp;  
  
I&nbsp;did&nbsp;all&nbsp;this&nbsp;work&nbsp;in&nbsp;the&nbsp;server&nbsp;side&nbsp;with&nbsp;the&nbsp;OnTrackShapeFinished&nbsp;event.&nbsp;The&nbsp;problem&nbsp;is&nbsp;that&nbsp;each&nbsp;time&nbsp;the&nbsp;user&nbsp;draw&nbsp;something,&nbsp;a&nbsp;postback&nbsp;occurs&nbsp;so&nbsp;that&nbsp;the&nbsp;background&nbsp;(google&nbsp;map&nbsp;in&nbsp;my&nbsp;case)&nbsp;refreshes,&nbsp;the&nbsp;editlayers&nbsp;refreshes&nbsp;as&nbsp;well.  
  
  
  
My&nbsp;question&nbsp;is&nbsp;:&nbsp;can&nbsp;I&nbsp;do&nbsp;that&nbsp;entirely&nbsp;in&nbsp;the&nbsp;client&nbsp;side.&nbsp;do&nbsp;you&nbsp;provide&nbsp;the&nbsp;same&nbsp;control&nbsp;as&nbsp;the&nbsp;server&nbsp;side?  
  
  
  
Thanks&nbsp;in&nbsp;advance.  
  
  
  
Sebastien.

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [June 26, 2009, 10:26am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/2 "2009-06-26T10:26:20Z")

</div>

Hi&nbsp;Sebastien,  
  
  
  
Actually,&nbsp;we&nbsp;have&nbsp;OpenLayers&nbsp;library&nbsp;as&nbsp;our&nbsp;client&nbsp;control;&nbsp;but&nbsp;I&nbsp;cannot&nbsp;find&nbsp;the&nbsp;functions&nbsp;you&nbsp;mentioned&nbsp;except&nbsp;“Intersects”&nbsp;method.&nbsp;OpenLayers&nbsp;supports&nbsp;more&nbsp;client&nbsp;functions&nbsp;for&nbsp;modifying&nbsp;the&nbsp;client&nbsp;shapes&nbsp;such&nbsp;as&nbsp;rotate,&nbsp;move,&nbsp;transform,&nbsp;etc.

If&nbsp;you&nbsp;are&nbsp;interesting&nbsp;in&nbsp;this,&nbsp;please&nbsp;refer&nbsp;to:  
  
[dev.openlayers.org/releases/...ng-js.html](http://dev.openlayers.org/releases/OpenLayers-2.7/doc/devdocs/files/OpenLayers/Geometry/LinearRing-js.html)

I&nbsp;have&nbsp;two&nbsp;recommendations.&nbsp;One&nbsp;is&nbsp;using&nbsp;server-side&nbsp;API.&nbsp;In&nbsp;the&nbsp;post&nbsp;back,&nbsp;just&nbsp;refresh&nbsp;the&nbsp;Overlay&nbsp;you&nbsp;need,&nbsp;and&nbsp;put&nbsp;the&nbsp;map&nbsp;in&nbsp;an&nbsp;update&nbsp;panel,&nbsp;set&nbsp;a&nbsp;client&nbsp;cache&nbsp;for&nbsp;baseOverlays&nbsp;which&nbsp;are&nbsp;not&nbsp;usually&nbsp;changed.

While&nbsp;another&nbsp;recommendation&nbsp;is&nbsp;still&nbsp;using&nbsp;server-side&nbsp;API;&nbsp;but&nbsp;this&nbsp;time,&nbsp;you&nbsp;can&nbsp;wrap&nbsp;a&nbsp;static&nbsp;web&nbsp;method&nbsp;for&nbsp;callback.&nbsp;I&nbsp;think&nbsp;this&nbsp;is&nbsp;the&nbsp;best&nbsp;way&nbsp;to&nbsp;do&nbsp;it&nbsp;on&nbsp;client&nbsp;side;&nbsp;because&nbsp;it&nbsp;maintains&nbsp;the&nbsp;same&nbsp;algorism&nbsp;between&nbsp;client&nbsp;and&nbsp;server&nbsp;side.

For&nbsp;example,&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;find&nbsp;the&nbsp;feature&nbsp;whether&nbsp;is&nbsp;“Contains”&nbsp;another&nbsp;feature,&nbsp;just&nbsp;transfer&nbsp;the&nbsp;WKT&nbsp;of&nbsp;the&nbsp;features&nbsp;to&nbsp;server&nbsp;side,&nbsp;and&nbsp;then&nbsp;restore&nbsp;the&nbsp;shapes&nbsp;on&nbsp;the&nbsp;server&nbsp;side,&nbsp;call&nbsp;“Contains”&nbsp;method&nbsp;and&nbsp;transfer&nbsp;back&nbsp;the&nbsp;result&nbsp;to&nbsp;client.&nbsp;It’s&nbsp;all&nbsp;asynchronizing&nbsp;so&nbsp;that&nbsp;the&nbsp;map&nbsp;will&nbsp;not&nbsp;fresh.

If&nbsp;you&nbsp;have&nbsp;any&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know.  
  
  
  
Thanks,  
  
Howard

---

<div class="post-metadata">

**Author:** ![sebastien](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sebastien](https://community.thinkgeo.com/u/sebastien)\
**Post date:** [June 26, 2009, 10:54am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/3 "2009-06-26T10:54:04Z")

</div>

why&nbsp;do&nbsp;you&nbsp;recomand&nbsp;not&nbsp;to&nbsp;use&nbsp;openlayers&nbsp;?&nbsp;do&nbsp;they&nbsp;provide&nbsp;bad&nbsp;quality&nbsp;services?

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [June 26, 2009, 11:29am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/4 "2009-06-26T11:29:23Z")

</div>

Sebastien,&nbsp;  
&nbsp;&nbsp;  
&nbsp;OpenLayers&nbsp;doesn’t&nbsp;support&nbsp;the&nbsp;functions&nbsp;you&nbsp;needed&nbsp;except&nbsp;“Contains”&nbsp;which&nbsp;you&nbsp;can&nbsp;verify&nbsp;from&nbsp;the&nbsp;link&nbsp;I&nbsp;pasted&nbsp;just&nbsp;now.&nbsp;Also,&nbsp;when&nbsp;you&nbsp;use&nbsp;the&nbsp;OpenLayers,&nbsp;you&nbsp;need&nbsp;to&nbsp;convert&nbsp;our&nbsp;geometry&nbsp;to&nbsp;their&nbsp;geometry&nbsp;type&nbsp;before&nbsp;you&nbsp;using&nbsp;that.&nbsp;I&nbsp;think&nbsp;it’s&nbsp;a&nbsp;little&nbsp;difficutle&nbsp;for&nbsp;normal&nbsp;customer&nbsp;who&nbsp;doesn’t&nbsp;know&nbsp;much&nbsp;about&nbsp;OpenLayers.&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;you&nbsp;have&nbsp;any&nbsp;queries&nbsp;please&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Howard

---

<div class="post-metadata">

**Author:** ![sebastien](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sebastien](https://community.thinkgeo.com/u/sebastien)\
**Post date:** [June 29, 2009, 2:22am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/5 "2009-06-29T02:22:08Z")

</div>

i&nbsp;tried&nbsp;the&nbsp;second&nbsp;solution&nbsp;:&nbsp;put&nbsp;the&nbsp;map&nbsp;inside&nbsp;an&nbsp;update&nbsp;panel.&nbsp;It&nbsp;works&nbsp;pretty&nbsp;well.&nbsp;&nbsp;  
&nbsp;I&nbsp;set&nbsp;the&nbsp;tool&nbsp;to&nbsp;be&nbsp;used&nbsp;with&nbsp;the&nbsp;clientside&nbsp;api,&nbsp;Map1.SetDrawMode(),&nbsp;the&nbsp;problem&nbsp;is&nbsp;each&nbsp;time&nbsp;I&nbsp;draw&nbsp;sth&nbsp;on&nbsp;the&nbsp;map,&nbsp;I&nbsp;make&nbsp;a&nbsp;postback&nbsp;to&nbsp;execute&nbsp;the&nbsp;process&nbsp;of&nbsp;merging&nbsp;intersecting&nbsp;etc&nbsp;the&nbsp;features&nbsp;and&nbsp;i&nbsp;lost&nbsp;the&nbsp;mode&nbsp;used.&nbsp;I&nbsp;know&nbsp;it&nbsp;is&nbsp;possible&nbsp;for&nbsp;me&nbsp;to&nbsp;change&nbsp;mode&nbsp;serverside&nbsp;but&nbsp;on&nbsp;client&nbsp;side&nbsp;it&nbsp;is&nbsp;faster.&nbsp;  
&nbsp;&nbsp;  
&nbsp;thanks&nbsp;in&nbsp;advance

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [June 29, 2009, 2:28pm UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/6 "2009-06-29T14:28:51Z")

</div>

Sebastien,  
  
  
  
Good&nbsp;to&nbsp;hear&nbsp;that&nbsp;you&nbsp;make&nbsp;it.&nbsp;The&nbsp;draw&nbsp;mode&nbsp;lost&nbsp;because&nbsp;we&nbsp;don’t&nbsp;synchronize&nbsp;the&nbsp;states&nbsp;which&nbsp;modified&nbsp;by&nbsp;client&nbsp;scripts&nbsp;just&nbsp;like&nbsp;normal&nbsp;web&nbsp;controls.  
  
  
  
You&nbsp;still&nbsp;can&nbsp;handle&nbsp;the&nbsp;client&nbsp;states&nbsp;which&nbsp;are&nbsp;changed&nbsp;by&nbsp;client&nbsp;scripts.&nbsp;Please&nbsp;see&nbsp;the&nbsp;attached&nbsp;sample&nbsp;for&nbsp;detail.  
  
  
  
Hope&nbsp;it&nbsp;helps.&nbsp;If&nbsp;you&nbsp;have&nbsp;any&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know.  
  
  
  
Thanks,  
  
Howard

[829-MapShapes.zip](https://community.thinkgeo.com/uploads/default/original/2X/c/c1476d97032551c06f989962e2a70eb806191f55.zip) (2.16 KB)

---

<div class="post-metadata">

**Author:** ![sebastien](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sebastien](https://community.thinkgeo.com/u/sebastien)\
**Post date:** [June 30, 2009, 2:59am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/7 "2009-06-30T02:59:50Z")

</div>

do&nbsp;you&nbsp;confirm&nbsp;that&nbsp;&nbsp;Map1.SetDrawMode(‘Modify’)&nbsp;in&nbsp;the&nbsp;clientside&nbsp;&nbsp;is&nbsp;TrackMode.Edit&nbsp;in&nbsp;the&nbsp;serverside?

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [June 30, 2009, 9:34am UTC](https://community.thinkgeo.com/t/draw-features-to-interact-with-existing-ones/4871/8 "2009-06-30T09:34:48Z")

</div>

Sebastien,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yes,&nbsp;they&nbsp;do&nbsp;the&nbsp;same&nbsp;thing&nbsp;that&nbsp;to&nbsp;change&nbsp;the&nbsp;map&nbsp;to&nbsp;the&nbsp;modify&nbsp;mode.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;In&nbsp;my&nbsp;last&nbsp;demo,&nbsp;I&nbsp;have&nbsp;a&nbsp;hidden&nbsp;field&nbsp;which&nbsp;synchronizes&nbsp;the&nbsp;track&nbsp;mode&nbsp;to&nbsp;the&nbsp;server&nbsp;side.&nbsp;On&nbsp;the&nbsp;server&nbsp;side&nbsp;I&nbsp;use&nbsp;reflection&nbsp;to&nbsp;cast&nbsp;the&nbsp;string&nbsp;back&nbsp;to&nbsp;its&nbsp;real&nbsp;type.&nbsp;But&nbsp;I&nbsp;didn’t&nbsp;take&nbsp;care&nbsp;of&nbsp;all&nbsp;the&nbsp;situations&nbsp;for&nbsp;it’s&nbsp;a&nbsp;demo.&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;you&nbsp;need&nbsp;synchronize&nbsp;modify&nbsp;mode&nbsp;please&nbsp;change&nbsp;saving&nbsp;“Modify”&nbsp;to&nbsp;“Edit”&nbsp;into&nbsp;the&nbsp;hidden&nbsp;field&nbsp;please.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Howard
