The tile styling demo in Sandbox has a great feature to Color by Distance to Selected Location:
The code from this function is:
// Color the buildings based on their distance from a selected central location
function colorByDistanceToCoordinate(pickedLatitude, pickedLongitude) {
osmBuildingsTileset.style = new Cesium.Cesium3DTileStyle({
defines: {
distance:
“distance(vec2(${feature[‘cesium#longitude’]}, ${feature[‘cesium#latitude’]}), vec2(” +
pickedLongitude +
“,” +
pickedLatitude +
“))”,
},
color: {
conditions: [
[“${distance} > 0.014”, “color(‘blue’)”],
[“${distance} > 0.010”, “color(‘green’)”],
[“${distance} > 0.006”, “color(‘yellow’)”],
[“${distance} > 0.0001”, “color(‘red’)”],
[“true”, “color(‘white’)”],
],
},
});
}
I would like to have buildings styled based on multiple locations (pins), not just one picked location. For example, assume there are three pins marked on the map. Each building then does a distance check against each pin, and the distance that is returned is the nearest pin (shortest distance). If there are three pins, then in the function above, buildings that are > 0.0001 from each pin are colored red.
My question… is there a Cesium function that can check the distance of the nearest pin to each building, such that the ${distance} that is passed to conditions to styling is always the closest Pin?