# zIndex for mark and feature layer

**URL:** <https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842>\
**Category:** WPF\
**Created:** [July 19, 2015, 1:32am UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842 "2015-07-19T01:32:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miri](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@miri](https://community.thinkgeo.com/u/miri)\
**Post date:** [July 19, 2015, 1:32am UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842/1 "2015-07-19T01:32:25Z")

</div>

Hello  
  
I&nbsp;have&nbsp;two&nbsp;types&nbsp;of&nbsp;layers&nbsp;in&nbsp;my&nbsp;application:  
  
&nbsp;SimpleMarkerOverlay&nbsp;and&nbsp;InMemoryFeatureLayer&nbsp;(with&nbsp;is&nbsp;an&nbsp;LayerOverlay)  
  
I&nbsp;also&nbsp;have&nbsp;a&nbsp;"Dummy&nbsp;Layer"&nbsp;which&nbsp;represents&nbsp;the&nbsp;merge&nbsp;of&nbsp;&nbsp;all&nbsp;the&nbsp;entities&nbsp;in&nbsp;the&nbsp;SimpleMarkerOverlay&nbsp;&nbsp;and&nbsp;InMemoryFeatureLayer&nbsp;.&nbsp;(this&nbsp;is&nbsp;for&nbsp;UI&nbsp;purpose&nbsp;only)  
  
I&nbsp;display&nbsp;a&nbsp;tree&nbsp;view&nbsp;of&nbsp;"Dummy&nbsp;layers"&nbsp;and&nbsp;I&nbsp;need&nbsp;to&nbsp;enable&nbsp;the&nbsp;user&nbsp;to&nbsp;change&nbsp;the&nbsp;Z&nbsp;order&nbsp;of&nbsp;the&nbsp;"dummy&nbsp;"&nbsp;layers  
  
This&nbsp;means&nbsp;that&nbsp;each&nbsp;time&nbsp;i&nbsp;change&nbsp;the&nbsp;ZIndex&nbsp;of&nbsp;InMemoryFeatureLayer,&nbsp;i&nbsp;need&nbsp;to&nbsp;also&nbsp;change&nbsp;the&nbsp;zindex&nbsp;of&nbsp;its&nbsp;corresponding&nbsp;&nbsp;SimpleMarkerOverlay.  
  
  
  
I&nbsp;have&nbsp;no&nbsp;problem&nbsp;to&nbsp;change&nbsp;the&nbsp;zIndex&nbsp;of&nbsp;&nbsp;SimpleMarkerOverlay.&nbsp;I&nbsp;simply&nbsp;chanage&nbsp;the&nbsp;location&nbsp;of&nbsp;the&nbsp;overlay&nbsp;inside&nbsp;the&nbsp;WpfMap.Overlayes&nbsp;collection  
  
But&nbsp;if&nbsp;I&nbsp;do&nbsp;that&nbsp;for&nbsp;a&nbsp;&nbsp;SimpleMarkerOverlay&nbsp;it&nbsp;does&nbsp;not&nbsp;have&nbsp;any&nbsp;affect.&nbsp;It&nbsp;seams&nbsp;that&nbsp;SimpleMarkerOverlay&nbsp;is&nbsp;always&nbsp;on&nbsp;top.  
  
  
  
I&nbsp;found&nbsp;the&nbsp;following&nbsp;example:but&nbsp;it&nbsp;only&nbsp;gives&nbsp;a&nbsp;solution&nbsp;regarding&nbsp;to&nbsp;change&nbsp;Zindex&nbsp;between&nbsp;several&nbsp;SimpleMarkerOverlay&nbsp;(and&nbsp;will&nbsp;not&nbsp;work&nbsp;if&nbsp;I&nbsp;have&nbsp;additional&nbsp;InMemoryFeatureLayer&nbsp;)  
  
[thinkgeo.com/forums/MapSuite/tabid/143/aft/10873/Default.aspx](http://thinkgeo.com/forums/MapSuite/tabid/143/aft/10873/Default.aspx)  
  
  
  
I&nbsp;also&nbsp;found&nbsp;the&nbsp;following&nbsp;example:but&nbsp;I&nbsp;think&nbsp;it&nbsp;does&nbsp;not&nbsp;help&nbsp;in&nbsp;my&nbsp;case  
  
[thinkgeo.com/forums/MapSuite/tabid/143/aft/7212/Default.aspx](http://thinkgeo.com/forums/MapSuite/tabid/143/aft/7212/Default.aspx)  
  
  
  
Can&nbsp;you&nbsp;please&nbsp;advise&nbsp;my&nbsp;on&nbsp;this&nbsp;issue?  
  
Thank&nbsp;you

---

<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:** [July 20, 2015, 3:31am UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842/2 "2015-07-20T03:31:03Z")

</div>

Hi&nbsp;Miri,&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;2nd&nbsp;link&nbsp;is&nbsp;for&nbsp;web,&nbsp;that’s&nbsp;different&nbsp;for&nbsp;WPF&nbsp;so&nbsp;it&nbsp;isn’t&nbsp;helpful.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;change&nbsp;zindex&nbsp;don’t&nbsp;works&nbsp;because&nbsp;some&nbsp;of&nbsp;our&nbsp;logic&nbsp;reorder&nbsp;the&nbsp;overlay.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Could&nbsp;you&nbsp;please&nbsp;try&nbsp;like&nbsp;this:&nbsp;  
&nbsp;&nbsp;  
&nbsp;wpfMap1.OverlayDrawing&nbsp;+=&nbsp;new&nbsp;System.EventHandler\<OverlayDrawingWpfMapEventArgs\>(wpfMap1\_OverlayDrawing);&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;void&nbsp;wpfMap1\_OverlayDrawing(object&nbsp;sender,&nbsp;OverlayDrawingWpfMapEventArgs&nbsp;e)&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Loop&nbsp;all&nbsp;overlays&nbsp;and&nbsp;reset&nbsp;z-index&nbsp;here&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;let&nbsp;me&nbsp;know&nbsp;whether&nbsp;that&nbsp;works&nbsp;for&nbsp;you.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don

---

<div class="post-metadata">

**Author:** ![miri](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@miri](https://community.thinkgeo.com/u/miri)\
**Post date:** [July 20, 2015, 7:59am UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842/3 "2015-07-20T07:59:57Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;answer,&nbsp;but&nbsp;I&nbsp;did&nbsp;not&nbsp;fully&nbsp;understood&nbsp;you  
  
What&nbsp;do&nbsp;you&nbsp;mean&nbsp;buy&nbsp;"reset&nbsp;Z&nbsp;index&nbsp;"&nbsp;inside&nbsp;the&nbsp;event&nbsp;handler.  
  
For&nbsp;my&nbsp;understanding&nbsp;the&nbsp;Z&nbsp;Index&nbsp;is&nbsp;been&nbsp;controlled&nbsp;by&nbsp;changing&nbsp;the&nbsp;position&nbsp;of&nbsp;the&nbsp;Overlay&nbsp;inside&nbsp;the&nbsp;WpfMap.Overlays&nbsp;collection  
  
  
  
In&nbsp;my&nbsp;application&nbsp;I&nbsp;changed&nbsp;the&nbsp;position&nbsp;(when&nbsp;receiving&nbsp;a&nbsp;trigger&nbsp;of&nbsp;user&nbsp;operation&nbsp;in&nbsp;the&nbsp;UI)&nbsp;of&nbsp;SimpalMarkersOverlays&nbsp;in&nbsp;the&nbsp;WpfMap.Overlays&nbsp;,&nbsp;when&nbsp;I&nbsp;get&nbsp;to&nbsp;the&nbsp;event&nbsp;handler&nbsp;the&nbsp;position&nbsp;of&nbsp;the&nbsp;SimpalMarkersOverlays&nbsp;in&nbsp;the&nbsp;WpfMap.Overlays&nbsp;is&nbsp;good&nbsp;&nbsp;.&nbsp;So&nbsp;what&nbsp;do&nbsp;you&nbsp;mean&nbsp;by&nbsp;"reset&nbsp;the&nbsp;z&nbsp;Index).&nbsp;Can&nbsp;you&nbsp;explain&nbsp;what&nbsp;should&nbsp;I&nbsp;do&nbsp;in&nbsp;the&nbsp;event&nbsp;handler&nbsp;please?  
  
  
  
what&nbsp;do&nbsp;you&nbsp;mean&nbsp;by&nbsp;saying&nbsp;that&nbsp;you&nbsp;change&nbsp;the&nbsp;overlays&nbsp;order&nbsp;internally?&nbsp;WpfMap.Overlays&nbsp;collection&nbsp;is&nbsp;in&nbsp;my&nbsp;control.  
  
  
  
Thank&nbsp;you

---

<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:** [July 20, 2015, 8:30pm UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842/4 "2015-07-20T20:30:48Z")

</div>

Hi&nbsp;Miri,&nbsp;  
&nbsp;&nbsp;  
&nbsp;By&nbsp;default&nbsp;adjust&nbsp;order&nbsp;in&nbsp;Overlays&nbsp;will&nbsp;works.&nbsp;  
&nbsp;&nbsp;  
&nbsp;But&nbsp;it&nbsp;looks&nbsp;for&nbsp;WPF&nbsp;edition,&nbsp;the&nbsp;MarkerOverlay&nbsp;have&nbsp;higher&nbsp;priority&nbsp;and&nbsp;it&nbsp;will&nbsp;be&nbsp;keep&nbsp;shows&nbsp;on&nbsp;top,&nbsp;you&nbsp;cannot&nbsp;adjust&nbsp;this&nbsp;by&nbsp;modify&nbsp;the&nbsp;order&nbsp;in&nbsp;overlays&nbsp;collection.&nbsp;  
&nbsp;&nbsp;  
&nbsp;So&nbsp;you&nbsp;can&nbsp;only&nbsp;reset&nbsp;zindex&nbsp;for&nbsp;each&nbsp;overlay&nbsp;manual&nbsp;like&nbsp;this:&nbsp;  
&nbsp;&nbsp;  
&nbsp;System.Windows.Controls.Canvas.SetZIndex(yourOverlay.OverlayCanvas,&nbsp;newIndex);&nbsp;  
&nbsp;&nbsp;  
&nbsp;Wish&nbsp;that’s&nbsp;helpful.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don

---

<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:** [July 20, 2015, 8:37pm UTC](https://community.thinkgeo.com/t/zindex-for-mark-and-feature-layer/3842/5 "2015-07-20T20:37:00Z")

</div>

Hi&nbsp;Miri,&nbsp;  
&nbsp;&nbsp;  
&nbsp;About&nbsp;your&nbsp;scenario,&nbsp;I&nbsp;have&nbsp;another&nbsp;suggestion.&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;marker&nbsp;overlay&nbsp;is&nbsp;covered&nbsp;by&nbsp;other&nbsp;layer&nbsp;or&nbsp;overlay,&nbsp;the&nbsp;markers&nbsp;will&nbsp;be&nbsp;only&nbsp;a&nbsp;image,&nbsp;you&nbsp;cannot&nbsp;do&nbsp;any&nbsp;special&nbsp;operation&nbsp;for&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;So&nbsp;I&nbsp;think&nbsp;you&nbsp;can&nbsp;use&nbsp;InmemoryFeatureLayer&nbsp;instead&nbsp;of&nbsp;it&nbsp;if&nbsp;the&nbsp;marker&nbsp;overlay&nbsp;won’t&nbsp;be&nbsp;on&nbsp;top.&nbsp;If&nbsp;it&nbsp;be&nbsp;moved&nbsp;to&nbsp;top,&nbsp;just&nbsp;use&nbsp;MarkerOverlay&nbsp;again.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;it&nbsp;should&nbsp;be&nbsp;a&nbsp;better&nbsp;solution.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don
