Select to view content in your preferred language

Changing style of VectorTileLayer causes data to be fetched

128
2
Jump to solution
2 weeks ago
RyanSutcliffe
Frequent Contributor

A colleague pointed out that, when you change the style for a VectorTileLayer in the JavaScript Maps SDK, the browser goes and fetches tiles of data for that layer.

You can see/reproduce this behavior when looking at the CodePen example  posted  by  @UndralBatsukh in an earlier thread in this forum.

clicking a feature to change style causes fetches to serverclicking a feature to change style causes fetches to server

 

Is this to be expected? Is it possibly a bug?

I was about to implement this behavior with a "mouseover" event. This would cause it to fire quite frequently as the user moves their cursor around over various features (even with some debouce handling). I wasn't expecting it to initiate any data fetches because it is just changing the color of an existing layer style.

[I can reproduce behavior running latest 4.31 version of the API].

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

This is expected behavior. When calling setStyleLayer, even if it modifies an existing layer—or adds a new one—the layer may have a different query or layout. As a result, we need to access the PBF (protocol buffer) and reprocess the features to ensure they align with the updated configuration. We fetch pbf for visible tiles.

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

This is expected behavior. When calling setStyleLayer, even if it modifies an existing layer—or adds a new one—the layer may have a different query or layout. As a result, we need to access the PBF (protocol buffer) and reprocess the features to ensure they align with the updated configuration. We fetch pbf for visible tiles.

RyanSutcliffe
Frequent Contributor

Ah interesting thanks. I didn't think that queries or styling changes on the frontend would affect what was being fetched over the wire from the VectorTileServer. I figured it fetched everything as raw data and then drew what was needed according to whatever filters and/or styling rules were present on the ESRI layers.

0 Kudos