# Performance and loading issues with ValueStyle

**URL:** <https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122>\
**Category:** WebAPI\
**Created:** [May 28, 2018, 5:20pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122 "2018-05-28T17:20:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Matoso](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/douglas_matoso/32/24948_2.png) [@Douglas\_Matoso](https://community.thinkgeo.com/u/Douglas_Matoso)\
**Post date:** [May 28, 2018, 5:20pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/1 "2018-05-28T17:20:33Z")

</div>

Hello,

I’m trying to style a layer of road segments (a total of 2048 features created with `LineShape`) based on a feature value using `ValueStyle`, but some tiles are not loading.  
The request returns status code **200** , but with **content-length = 0** , and the ones that do load are taking 3 to 4 seconds each.

The way I’m setting the layer style is something like this:

```
var valueStyle = new ValueStyle();
valueStyle.ColumnName = "RoadStatus";
valueStyle.ValueItems.Add(new ValueItem("Open", new LineStyle(new GeoPen(GeoColor.FromHtml("#5181b2"), 3))));
valueStyle.ValueItems.Add(new ValueItem("Closed", new LineStyle(new GeoPen(GeoColor.FromHtml("#d13135"), 3))));

roadsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
roadsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

```

If I change the `ValueStyle` to a `LineStyle`, all tiles are rendered correctly:

```
roadsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.FromHtml("#5181b2"), 3));

```

I CPU profile shows the majority of CPU time (97%) is spent on `MapSuite.WebApi.Overlay::Draw`.

Do you have any idea where the problem may be?

Thanks!

---

<div class="post-metadata">

**Author:** ![Douglas\_Matoso](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/douglas_matoso/32/24948_2.png) [@Douglas\_Matoso](https://community.thinkgeo.com/u/Douglas_Matoso)\
**Post date:** [May 28, 2018, 5:26pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/2 "2018-05-28T17:26:58Z")

</div>

Just to add, I tried reducing the number of features to about 100, but that do not seem to improve the performance.

---

<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:** [May 29, 2018, 9:28am UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/3 "2018-05-29T09:28:20Z")

</div>

Hi Douglas\_Matoso,

I build a quickly sample which render the 100 lines, but it looks the CPU usage is well and I hadn’t reproduce your exception.

Could you please try this sample and modify it to reproduce your issue?

[9122.zip](https://community.thinkgeo.com/uploads/default/original/3X/5/b/5b189859b1cc99bbdcbb1f0f4417845fa3f1b024.zip) (11.1 KB)

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Douglas\_Matoso](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/douglas_matoso/32/24948_2.png) [@Douglas\_Matoso](https://community.thinkgeo.com/u/Douglas_Matoso)\
**Post date:** [May 29, 2018, 12:17pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/4 "2018-05-29T12:17:17Z")

</div>

Thanks, Ethan!

I’ll check it out and see what I’m doing differently.

Regards,

---

<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:** [May 30, 2018, 2:04am UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/5 "2018-05-30T02:04:47Z")

</div>

Hi Douglas\_Matoso,

Any update please let us know.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Douglas\_Matoso](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/douglas_matoso/32/24948_2.png) [@Douglas\_Matoso](https://community.thinkgeo.com/u/Douglas_Matoso)\
**Post date:** [May 30, 2018, 12:22pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/6 "2018-05-30T12:22:41Z")

</div>

Hi, Ethan!

I was getting a “Collection was modified; enumeration operation may not execute.” exception on `layerOverlay.Draw(geoCanvas);`.

The only difference I noticed was that I was creating the `InMemoryFeatureLayer` object only once and reusing on every request, and in your example you create a new object every time. I changed my code and the problem is gone.

I’m still a little confused because I have that `InMemoryFeatureLayer` reuse in other layers without problems. Even when I change your example to create that object only once, the problem doesn’t occur.

Thanks!

---

<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:** [May 31, 2018, 3:15am UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/7 "2018-05-31T03:15:16Z")

</div>

Hi Douglas\_Matoso,

For WebAPI I think it won’t save the status, so could you let me know where you save the InMemoryFeatureLayer in server side?

Have you tried to save LayerOverlay instead of the Layer?

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Douglas\_Matoso](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/douglas_matoso/32/24948_2.png) [@Douglas\_Matoso](https://community.thinkgeo.com/u/Douglas_Matoso)\
**Post date:** [June 4, 2018, 2:14pm UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/8 "2018-06-04T14:14:28Z")

</div>

Hi Ethan,

We were creating it on first request, and on subsequent ones we just returned the already created object. We refactored to create it on every request, and we didn’t see any degradation in performance, so we decided to leave it that way.

Thanks for your support.

---

<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:** [June 5, 2018, 1:42am UTC](https://community.thinkgeo.com/t/performance-and-loading-issues-with-valuestyle/9122/9 "2018-06-05T01:42:27Z")

</div>

Hi Douglas\_Matoso,

I am glad to hear you find a solution for it.

Any question please let us know.

Regards,

Ethan
