[Maps] updated scaled property values when there are no results (#37121) (#37474)

This commit is contained in:
Nathan Reese 2019-05-30 07:33:39 -06:00 committed by GitHub
parent 932b84cb7e
commit a30dc7dae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -312,11 +312,7 @@ export class VectorStyle extends AbstractStyle {
range: this._getFieldRange(name),
computedName: VectorStyle.getComputedFieldName(name),
};
})
.filter(({ range }) => {
return !!range;
});
}
clearFeatureState(featureCollection, mbMap, sourceId) {
@ -352,11 +348,12 @@ export class VectorStyle extends AbstractStyle {
//scale to [0,1] domain
for (let i = 0; i < featureCollection.features.length; i++) {
const feature = featureCollection.features[i];
for (let j = 0; j < scaledFields.length; j++) {
const { name, range, computedName } = scaledFields[j];
const unscaledValue = parseFloat(feature.properties[name]);
let scaledValue;
if (isNaN(unscaledValue)) {//cannot scale
if (isNaN(unscaledValue) || !range) {//cannot scale
scaledValue = -1;//put outside range
} else if (range.delta === 0) {//values are identical
scaledValue = 1;//snap to end of color range
@ -389,7 +386,8 @@ export class VectorStyle extends AbstractStyle {
_getMbDataDrivenSize({ fieldName, minSize, maxSize }) {
const targetName = VectorStyle.getComputedFieldName(fieldName);
return ['interpolate',
return [
'interpolate',
['linear'],
['feature-state', targetName],
0, minSize,