# Hangup problem in displaying multiple map layers read from xml file

**URL:** <https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967>\
**Category:** WPF\
**Created:** [March 21, 2011, 2:47am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967 "2011-03-21T02:47:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![franklin1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@franklin1](https://community.thinkgeo.com/u/franklin1)\
**Post date:** [March 21, 2011, 2:47am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/1 "2011-03-21T02:47:24Z")

</div>

Hi&nbsp;Tsui,

&nbsp;&nbsp;&nbsp;I&nbsp;am&nbsp;testing&nbsp;a&nbsp;mapManager&nbsp;class&nbsp;which&nbsp;can&nbsp;read&nbsp;map&nbsp;layer&nbsp;shape&nbsp;files&nbsp;from&nbsp;a&nbsp;xml&nbsp;configuration&nbsp;file&nbsp;and&nbsp;display&nbsp;the&nbsp;layers&nbsp;correctly&nbsp;in&nbsp;a&nbsp;WGS84&nbsp;map.&nbsp;Everything&nbsp;goes&nbsp;well&nbsp;except&nbsp;that&nbsp;when&nbsp;the&nbsp;final&nbsp;layer&nbsp;shape&nbsp;file&nbsp;is&nbsp;processed,&nbsp;the&nbsp;map&nbsp;loader&nbsp;application&nbsp;cannot&nbsp;respond&nbsp;to&nbsp;any&nbsp;Map&nbsp;GUI&nbsp;action,&nbsp;such&nbsp;as&nbsp;zoom&nbsp;in/out&nbsp;&nbsp;and&nbsp;seems&nbsp;getting&nbsp;stuck&nbsp;at&nbsp;the&nbsp;display&nbsp;for&nbsp;ever.&nbsp;I&nbsp;call&nbsp;the&nbsp;loadMapFromXml&nbsp;method&nbsp;in&nbsp;Wpf\_MapLoaded.&nbsp;What&nbsp;could&nbsp;be&nbsp;the&nbsp;problem?&nbsp;Thanks.

Franklin

[002\_001\_MapLoaderClass.txt](https://community.thinkgeo.com/uploads/default/original/1X/2fc35577652736e2fd19311f3ba053bbc8b464a0.txt) (5.28 KB)

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [March 21, 2011, 4:31am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/2 "2011-03-21T04:31:30Z")

</div>

Franklin,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;sample&nbsp;code,&nbsp;I&nbsp;review&nbsp;line&nbsp;by&nbsp;line&nbsp;but&nbsp;I&nbsp;didn’t&nbsp;find&nbsp;any&nbsp;code&nbsp;may&nbsp;cause&nbsp;the&nbsp;problem.&nbsp;Could&nbsp;you&nbsp;provide&nbsp;your&nbsp;xml&nbsp;file&nbsp;as&nbsp;well&nbsp;so&nbsp;that&nbsp;I&nbsp;can&nbsp;reproduce&nbsp;your&nbsp;problem&nbsp;at&nbsp;my&nbsp;machine?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;James

---

<div class="post-metadata">

**Author:** ![franklin1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@franklin1](https://community.thinkgeo.com/u/franklin1)\
**Post date:** [March 21, 2011, 10:29pm UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/3 "2011-03-21T22:29:07Z")

</div>

James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Have&nbsp;uploaded&nbsp;the&nbsp;xml&nbsp;file&nbsp;to&nbsp;Ticket&nbsp;3424.&nbsp;Please&nbsp;take&nbsp;a&nbsp;look&nbsp;there.&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Franklin

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [March 22, 2011, 12:43am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/4 "2011-03-22T00:43:51Z")

</div>

Franklin,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;you&nbsp;add&nbsp;staticOverlay&nbsp;too&nbsp;many&nbsp;times,&nbsp;you&nbsp;can&nbsp;try&nbsp;to&nbsp;move&nbsp;“wpfMap1.Overlays.Add(staticOverlay);”&nbsp;outside&nbsp;the&nbsp;while&nbsp;loop&nbsp;because&nbsp;you&nbsp;only&nbsp;need&nbsp;to&nbsp;add&nbsp;it&nbsp;once.&nbsp;And&nbsp;also&nbsp;you&nbsp;set&nbsp;CurrentExtent&nbsp;every&nbsp;time&nbsp;and&nbsp;refresh&nbsp;wpfMap&nbsp;every&nbsp;time&nbsp;for&nbsp;each&nbsp;layer,&nbsp;I&nbsp;don’t&nbsp;know&nbsp;what&nbsp;your&nbsp;intention&nbsp;but&nbsp;you&nbsp;can&nbsp;move&nbsp;them&nbsp;out&nbsp;of&nbsp;the&nbsp;while&nbsp;loop&nbsp;and&nbsp;just&nbsp;call&nbsp;them&nbsp;once&nbsp;after&nbsp;loading&nbsp;all&nbsp;layers.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;James

---

<div class="post-metadata">

**Author:** ![franklin1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@franklin1](https://community.thinkgeo.com/u/franklin1)\
**Post date:** [March 22, 2011, 1:03am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/5 "2011-03-22T01:03:14Z")

</div>

James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;Logically&nbsp;you&nbsp;are&nbsp;correct.&nbsp;I&nbsp;tried&nbsp;this&nbsp;outside&nbsp;the&nbsp;while&nbsp;loop&nbsp;several&nbsp;times&nbsp;already&nbsp;but&nbsp;nothing&nbsp;would&nbsp;be&nbsp;shown&nbsp;in&nbsp;the&nbsp;map&nbsp;area.&nbsp;So&nbsp;I&nbsp;was&nbsp;forced&nbsp;to&nbsp;the&nbsp;present&nbsp;approach,&nbsp;because&nbsp;at&nbsp;least&nbsp;it&nbsp;shows&nbsp;all&nbsp;the&nbsp;layers.&nbsp;Do&nbsp;you&nbsp;know&nbsp;why&nbsp;this&nbsp;weird&nbsp;thing&nbsp;happen?

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [March 22, 2011, 2:12am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/6 "2011-03-22T02:12:59Z")

</div>

Franklin,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;your&nbsp;code&nbsp;might&nbsp;be&nbsp;wrong,&nbsp;could&nbsp;you&nbsp;provide&nbsp;the&nbsp;code&nbsp;which&nbsp;you&nbsp;put&nbsp;all&nbsp;metioned&nbsp;staff&nbsp;out&nbsp;of&nbsp;the&nbsp;while&nbsp;loop?&nbsp;And&nbsp;I&nbsp;can&nbsp;review&nbsp;again&nbsp;to&nbsp;check&nbsp;if&nbsp;I&nbsp;can&nbsp;find&nbsp;the&nbsp;problem.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;James

---

<div class="post-metadata">

**Author:** ![franklin1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@franklin1](https://community.thinkgeo.com/u/franklin1)\
**Post date:** [March 22, 2011, 2:43am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/7 "2011-03-22T02:43:38Z")

</div>

I&nbsp;moved&nbsp;the&nbsp;following&nbsp;lines&nbsp;outside&nbsp;the&nbsp;loop&nbsp;and&nbsp;placed&nbsp;them&nbsp;just&nbsp;above&nbsp;&nbsp;ShpFileTable[0].Close()&nbsp;(refer&nbsp;to&nbsp;the&nbsp;MapLoader&nbsp;txt&nbsp;file&nbsp;above)&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;wpfMap1.Overlays.Add(staticOverlay);&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((!ShpFileTable[0].IsOpen&nbsp;==&nbsp;true)&nbsp;&&&nbsp;(ShpFileTable[0]&nbsp;!=&nbsp;null))&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShpFileTable[0].Open();&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RectangleShape&nbsp;extBox&nbsp;=&nbsp;ShpFileTable[0].GetBoundingBox();&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wpfMap1.CurrentExtent&nbsp;=&nbsp;extBox;&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wpfMap1.Refresh();&nbsp;  
&nbsp;&nbsp;  
&nbsp;Then&nbsp;nothing&nbsp;could&nbsp;be&nbsp;shown&nbsp;in&nbsp;the&nbsp;map&nbsp;area&nbsp;when&nbsp;the&nbsp;method&nbsp;is&nbsp;called&nbsp;in&nbsp;Wpf\_MapLoaded.&nbsp;Why?

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [March 22, 2011, 4:13am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/8 "2011-03-22T04:13:22Z")

</div>

Franklin,

That's&nbsp;weird&nbsp;I&nbsp;don't&nbsp;know&nbsp;what&nbsp;your&nbsp;problem.&nbsp;Could&nbsp;you&nbsp;do&nbsp;the&nbsp;following&nbsp;test&nbsp;to&nbsp;verify&nbsp;if&nbsp;the&nbsp;problem&nbsp;is&nbsp;caused&nbsp;by&nbsp;MapSuite&nbsp;or&nbsp;not?

Don't&nbsp;use&nbsp;xml&nbsp;file,&nbsp;just&nbsp;write&nbsp;code&nbsp;like&nbsp;our&nbsp;HowDoI&nbsp;samples,&nbsp;create&nbsp;16&nbsp;ShapeFileFeatureLayer&nbsp;and&nbsp;set&nbsp;the&nbsp;specific&nbsp;styles&nbsp;and&nbsp;apply&nbsp;to&nbsp;zoom&nbsp;level&nbsp;20,&nbsp;add&nbsp;all&nbsp;layers&nbsp;to&nbsp;static&nbsp;overlay,&nbsp;and&nbsp;then&nbsp;add&nbsp;static&nbsp;overlay&nbsp;to&nbsp;wpfMap,&nbsp;set&nbsp;MapUnit,&nbsp;CurrentExtent,&nbsp;call&nbsp;Refresh(),&nbsp;such&nbsp;as&nbsp;following&nbsp;code.&nbsp;If&nbsp;it&nbsp;works&nbsp;that&nbsp;means&nbsp;it's&nbsp;not&nbsp;the&nbsp;MapSuite's&nbsp;issue,&nbsp;If&nbsp;it&nbsp;still&nbsp;has&nbsp;problem,&nbsp;please&nbsp;provide&nbsp;the&nbsp;code&nbsp;and&nbsp;we&nbsp;can&nbsp;figure&nbsp;out&nbsp;how&nbsp;to&nbsp;fix&nbsp;it.

`            LayerOverlay staticOverlay = new LayerOverlay();            ShapeFileFeatureLayer ShapeFileFeatureLayer1 = new ShapeFileFeatureLayer(path1);            ShapeFileFeatureLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = yourAreaStyle1;            ShapeFileFeatureLayer1.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = yourLineStyle1;            ShapeFileFeatureLayer1.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = yourPointStyle1;            ShapeFileFeatureLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            ShapeFileFeatureLayer1.DrawingMarginPercentage = 100;            ShapeFileFeatureLayer ShapeFileFeatureLayer1label = new ShapeFileFeatureLayer(path1);            ShapeFileFeatureLayer1label.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = yourTextStyle1;            ShapeFileFeatureLayer1label.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            ShapeFileFeatureLayer1label.DrawingMarginPercentage = 100;            staticOverlay.Layers.Add(layerName1, ShapeFileFeatureLayer1);            staticOverlay.Layers.Add(labelName1, ShapeFileFeatureLayer1label);            ShapeFileFeatureLayer ShapeFileFeatureLayer2 = new ShapeFileFeatureLayer(path2);            ShapeFileFeatureLayer2.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = yourAreaStyle2;            ShapeFileFeatureLayer2.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = yourLineStyle2;            ShapeFileFeatureLayer2.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = yourPointStyle2;            ShapeFileFeatureLayer2.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            ShapeFileFeatureLayer2.DrawingMarginPercentage = 100;            ShapeFileFeatureLayer ShapeFileFeatureLayer2label = new ShapeFileFeatureLayer(path2);            ShapeFileFeatureLayer2label.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = yourTextStyle2;            ShapeFileFeatureLayer2label.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            ShapeFileFeatureLayer2label.DrawingMarginPercentage = 100;            staticOverlay.Layers.Add(layerName2, ShapeFileFeatureLayer2);            staticOverlay.Layers.Add(labelName2, ShapeFileFeatureLayer1label);            // do the same way for other shape files            ...            wpfMap1.Overlays.Add(staticOverlay);            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;            wpfMap1.CurrentExtent = new RectangleShape(-180, 90, 180, -90);            wpfMap1.Refresh();`

Thanks,

James

---

<div class="post-metadata">

**Author:** ![Klaus3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/e5b9ba/32.png) [@Klaus3](https://community.thinkgeo.com/u/Klaus3)\
**Post date:** [March 22, 2011, 8:50am UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/9 "2011-03-22T08:50:57Z")

</div>

Franklin,&nbsp;does&nbsp;the&nbsp;shapefile&nbsp;order&nbsp;matter?&nbsp;&nbsp;Is&nbsp;there&nbsp;something&nbsp;special&nbsp;about&nbsp;the&nbsp;final&nbsp;shapefile&nbsp;being&nbsp;read?&nbsp;&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![franklin1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@franklin1](https://community.thinkgeo.com/u/franklin1)\
**Post date:** [March 22, 2011, 9:37pm UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/10 "2011-03-22T21:37:07Z")

</div>

Hi&nbsp;James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;had&nbsp;no&nbsp;problem&nbsp;in&nbsp;displaying&nbsp;multiple&nbsp;layer&nbsp;map&nbsp;following&nbsp;the&nbsp;conventional&nbsp;way.&nbsp;But&nbsp;it&nbsp;is&nbsp;very&nbsp;inconvenient&nbsp;if&nbsp;you&nbsp;have&nbsp;to&nbsp;do&nbsp;it&nbsp;in&nbsp;the&nbsp;hard&nbsp;coded&nbsp;way&nbsp;for&nbsp;deploying&nbsp;a&nbsp;map&nbsp;application,&nbsp;which&nbsp;is&nbsp;supposed&nbsp;to&nbsp;be&nbsp;run&nbsp;on&nbsp;any&nbsp;set&nbsp;of&nbsp;map&nbsp;shape&nbsp;files&nbsp;defined&nbsp;in&nbsp;the&nbsp;xml&nbsp;configuration&nbsp;file.&nbsp;  
&nbsp;I&nbsp;am&nbsp;solving&nbsp;the&nbsp;xml&nbsp;maploader&nbsp;problem,&nbsp;nothing&nbsp;else.&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Franklin

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [March 22, 2011, 9:56pm UTC](https://community.thinkgeo.com/t/hangup-problem-in-displaying-multiple-map-layers-read-from-xml-file/2967/11 "2011-03-22T21:56:49Z")

</div>

Franklin,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;you&nbsp;may&nbsp;misunderstand&nbsp;my&nbsp;point,&nbsp;I&nbsp;just&nbsp;want&nbsp;to&nbsp;make&nbsp;sure&nbsp;if&nbsp;the&nbsp;problem&nbsp;is&nbsp;caused&nbsp;by&nbsp;MapSuite&nbsp;or&nbsp;not,&nbsp;that&nbsp;way&nbsp;is&nbsp;just&nbsp;a&nbsp;test,&nbsp;not&nbsp;really&nbsp;suggest&nbsp;you&nbsp;do&nbsp;like&nbsp;that.&nbsp;So&nbsp;now&nbsp;I&nbsp;know&nbsp;the&nbsp;problem&nbsp;is&nbsp;caused&nbsp;by&nbsp;your&nbsp;xml&nbsp;parsing,&nbsp;you&nbsp;can&nbsp;add&nbsp;some&nbsp;trace&nbsp;to&nbsp;output&nbsp;the&nbsp;settings&nbsp;of&nbsp;each&nbsp;layer,&nbsp;and&nbsp;compare&nbsp;the&nbsp;hard&nbsp;coded&nbsp;setting,&nbsp;and&nbsp;then&nbsp;you&nbsp;will&nbsp;find&nbsp;which&nbsp;part&nbsp;is&nbsp;different.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;James
