# Problem with Applying projection to a InMemoryfeaturelayer on OnDragEnded event

**URL:** <https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618>\
**Category:** WPF\
**Created:** [February 20, 2014, 1:31am UTC](https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618 "2014-02-20T01:31:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maryam](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@maryam](https://community.thinkgeo.com/u/maryam)\
**Post date:** [February 20, 2014, 1:31am UTC](https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618/1 "2014-02-20T01:31:21Z")

</div>

Hi,  
  
  
  
I&nbsp;have&nbsp;a&nbsp;problem&nbsp;with&nbsp;applying&nbsp;projection&nbsp;to&nbsp;a&nbsp;InMemoryFeatureLayer&nbsp;that&nbsp;select&nbsp;in&nbsp;OnDragEnded&nbsp;event&nbsp;of&nbsp;TrackInteractiveOverlay:  
we&nbsp;have&nbsp;attached&nbsp;a&nbsp;sample&nbsp;&nbsp;to&nbsp;this&nbsp;post&nbsp;,&nbsp;and&nbsp;in&nbsp;our&nbsp;sample&nbsp;we&nbsp;describe&nbsp;two&nbsp;senario&nbsp;:  
  
  
  
1.&nbsp;if&nbsp;we&nbsp;select&nbsp;an&nbsp;area&nbsp;on&nbsp;my&nbsp;map&nbsp;by&nbsp;OnDragEnded&nbsp;event&nbsp;,and&nbsp;then&nbsp;apply&nbsp;bingMap&nbsp;to&nbsp;it&nbsp;,&nbsp;sample&nbsp;works&nbsp;fine.  
2.&nbsp;if&nbsp;we&nbsp;apply&nbsp;bingMap&nbsp;at&nbsp;first&nbsp;and&nbsp;then&nbsp;select&nbsp;an&nbsp;area&nbsp;on&nbsp;map&nbsp;by&nbsp;OnDragEnded&nbsp;event&nbsp;,&nbsp;nothing&nbsp;is&nbsp;selected&nbsp;.  
  
  
  
===============================  
in&nbsp;out&nbsp;sample&nbsp;,&nbsp;we&nbsp;create&nbsp;a&nbsp;mapControl&nbsp;that&nbsp;inherit&nbsp;from&nbsp;wpfMap&nbsp;and&nbsp;implement&nbsp;4&nbsp;action&nbsp;on&nbsp;it&nbsp;:  
  
  
  
-&nbsp;AddSource  
-&nbsp;ApplyMap  
-&nbsp;DeleteMap  
-&nbsp;Select&nbsp;area&nbsp;on&nbsp;map&nbsp;(&nbsp;OnDragEnded&nbsp;)&nbsp;.&nbsp;we&nbsp;need&nbsp;to&nbsp;work&nbsp;this&nbsp;operations&nbsp;on&nbsp;my&nbsp;map&nbsp;.  
  
  
  
  
  
can&nbsp;any&nbsp;one&nbsp;help&nbsp;me&nbsp;on&nbsp;this&nbsp;problem&nbsp;?  
  
  
  
thanks&nbsp;alot

---

<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:** [February 20, 2014, 8:14pm UTC](https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618/2 "2014-02-20T20:14:53Z")

</div>

Hi&nbsp;Maryam,  
  
  
  
I&nbsp;checked&nbsp;your&nbsp;sample&nbsp;and&nbsp;we&nbsp;don’t&nbsp;need&nbsp;to&nbsp;apply&nbsp;the&nbsp;projection&nbsp;on&nbsp;the&nbsp;selectionLayer&nbsp;in&nbsp;the&nbsp;DragEnded&nbsp;events.&nbsp;Comment&nbsp;out&nbsp;the&nbsp;below&nbsp;codes&nbsp;should&nbsp;fix&nbsp;the&nbsp;issue:

> `//if (MapType != MapTypes.None)`  
> `    ``//selectionLayer.FeatureSource.Projection = new Proj4Projection`  
> `    ``//{`  
> `    ``//    InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(27700),`  
> `    ``//    ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString()`  
> `    ``//};`

  
Actually,&nbsp;the&nbsp;selectionLayer&nbsp;projection&nbsp;is&nbsp;always&nbsp;the&nbsp;same&nbsp;as&nbsp;the&nbsp;base&nbsp;map&nbsp;like&nbsp;here&nbsp;Mercator&nbsp;as&nbsp;all&nbsp;the&nbsp;features&nbsp;in&nbsp;it&nbsp;are&nbsp;from&nbsp;TrackShapeLayer.&nbsp;In&nbsp;your&nbsp;layers,&nbsp;only&nbsp;the&nbsp;shape&nbsp;file&nbsp;under&nbsp;EPSG&nbsp;27700&nbsp;should&nbsp;do&nbsp;the&nbsp;projection&nbsp;and&nbsp;you&nbsp;have&nbsp;done&nbsp;that&nbsp;I&nbsp;saw.  
  
  
  
Hope&nbsp;it&nbsp;helps.  
  
Regards,  
  
Troy

---

<div class="post-metadata">

**Author:** ![maryam](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@maryam](https://community.thinkgeo.com/u/maryam)\
**Post date:** [February 21, 2014, 12:51am UTC](https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618/3 "2014-02-21T00:51:55Z")

</div>

thanks&nbsp;for&nbsp;your&nbsp;response&nbsp;.  
  
I&nbsp;did&nbsp;what&nbsp;you&nbsp;recommended&nbsp;,&nbsp;and&nbsp;this&nbsp;problem&nbsp;was&nbsp;resolved,&nbsp;  
  
but&nbsp;follow&nbsp;this&nbsp;:  
  
=====================  
  
1.&nbsp;select&nbsp;use&nbsp;bing&nbsp;map  
  
2.&nbsp;select&nbsp;area&nbsp;on&nbsp;map  
  
3.&nbsp;unselect&nbsp;use&nbsp;bing&nbsp;map  
  
============================  
  
you&nbsp;see&nbsp;that&nbsp;my&nbsp;selection&nbsp;disappears&nbsp;.  
  
  
  
would&nbsp;you&nbsp;help&nbsp;me&nbsp;on&nbsp;this&nbsp;new&nbsp;problem&nbsp;&nbsp;!  
  
  
  
thanks&nbsp;a&nbsp;lot&nbsp;

---

<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:** [February 23, 2014, 9:13pm UTC](https://community.thinkgeo.com/t/problem-with-applying-projection-to-a-inmemoryfeaturelayer-on-ondragended-event/3618/4 "2014-02-23T21:13:23Z")

</div>

Hi&nbsp;Maryam,  
  
  
  
Okay,&nbsp;the&nbsp;reason&nbsp;of&nbsp;the&nbsp;problem&nbsp;is&nbsp;still&nbsp;caused&nbsp;by&nbsp;the&nbsp;projection.&nbsp;In&nbsp;this&nbsp;case,&nbsp;when&nbsp;we&nbsp;unselect&nbsp;the&nbsp;bing&nbsp;map,&nbsp;we&nbsp;zoom&nbsp;the&nbsp;map&nbsp;to&nbsp;the&nbsp;extend&nbsp;which&nbsp;is&nbsp;under&nbsp;EPSG&nbsp;27700,&nbsp;however,&nbsp;the&nbsp;select&nbsp;layer&nbsp;is&nbsp;still&nbsp;under&nbsp;the&nbsp;Bing&nbsp;projection&nbsp;by&nbsp;default.&nbsp;So,&nbsp;in&nbsp;the&nbsp;deleteMap&nbsp;Method,&nbsp;we&nbsp;need&nbsp;to&nbsp;apply&nbsp;the&nbsp;EPSG&nbsp;27700&nbsp;to&nbsp;the&nbsp;select&nbsp;layer&nbsp;to&nbsp;fit&nbsp;the&nbsp;current&nbsp;extent&nbsp;changed.  
  
  
  
Personally,&nbsp;it&nbsp;is&nbsp;not&nbsp;a&nbsp;regular&nbsp;way&nbsp;to&nbsp;make&nbsp;the&nbsp;all&nbsp;kinds&nbsp;of&nbsp;layers&nbsp;to&nbsp;fit&nbsp;the&nbsp;shape&nbsp;file&nbsp;projection&nbsp;like&nbsp;your&nbsp;sample&nbsp;unless&nbsp;you&nbsp;have&nbsp;a&nbsp;special&nbsp;scenario,&nbsp;as&nbsp;that&nbsp;would&nbsp;bring&nbsp;a&nbsp;lot&nbsp;of&nbsp;projection&nbsp;conversions.&nbsp;The&nbsp;common&nbsp;way&nbsp;is&nbsp;we&nbsp;set&nbsp;a&nbsp;basic&nbsp;map&nbsp;projection&nbsp;like&nbsp;as&nbsp;Bing’s&nbsp;and&nbsp;then&nbsp;we&nbsp;only&nbsp;need&nbsp;to&nbsp;apply&nbsp;the&nbsp;corresponding&nbsp;projection&nbsp;on&nbsp;the&nbsp;other&nbsp;layers.&nbsp;For&nbsp;instance,&nbsp;the&nbsp;Bing&nbsp;or&nbsp;Google&nbsp;and&nbsp;the&nbsp;TrackShapeLayer&nbsp;are&nbsp;using&nbsp;the&nbsp;same&nbsp;projection&nbsp;and&nbsp;only&nbsp;the&nbsp;shape&nbsp;file&nbsp;is&nbsp;using&nbsp;the&nbsp;ESPS&nbsp;27700.&nbsp;So&nbsp;we&nbsp;only&nbsp;do&nbsp;the&nbsp;projection&nbsp;conversion&nbsp;on&nbsp;the&nbsp;shape&nbsp;file&nbsp;at&nbsp;the&nbsp;first.&nbsp;Then&nbsp;we&nbsp;don’t&nbsp;need&nbsp;to&nbsp;do&nbsp;the&nbsp;projection&nbsp;any&nbsp;more.  
I&nbsp;also&nbsp;attached&nbsp;the&nbsp;modified&nbsp;sample&nbsp;to&nbsp;show&nbsp;what&nbsp;I&nbsp;am&nbsp;saying&nbsp;and&nbsp;I&nbsp;also&nbsp;did&nbsp;some&nbsp;enhancements&nbsp;like&nbsp;using&nbsp;only&nbsp;one&nbsp;select&nbsp;layer&nbsp;instance&nbsp;rather&nbsp;insert&nbsp;a&nbsp;new&nbsp;layer&nbsp;in&nbsp;each&nbsp;drag&nbsp;end&nbsp;events.  
  
  
  
If&nbsp;there&nbsp;is&nbsp;any&nbsp;thing&nbsp;confused&nbsp;on&nbsp;the&nbsp;explanation&nbsp;or&nbsp;the&nbsp;sample,&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know.  
Regards,  
Troy  
  
[post11824.txt](https://community.thinkgeo.com/uploads/default/original/2X/b/b68c365a5cdb983fa3790d34ee97d11328cede64.txt) (5.28 KB)
