Skip to content

[Bug]: HeatmapLayer does not respect filter like other layers #4215

@ted-mundy

Description

@ted-mundy

Mapbox Version

default

React Native Version

0.83.6

Platform

iOS

@rnmapbox/maps version

10.3.1

Standalone component to reproduce

import React from 'react';
import {
  MapView,
  ShapeSource,
  HeatmapLayer,
  Camera,
} from '@rnmapbox/maps';

const features = {
  type: 'FeatureCollection',
  features: [
    { type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [-0.1276, 51.5074] }, properties: { weight: 1.0 } },
    { type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [-0.0750, 51.5225] }, properties: { weight: 0.8 } },
    { type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [-0.1425, 51.5390] }, properties: { weight: 0.7 } },
    { type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [-0.0235, 51.5054] }, properties: { weight: 0.6 } },
    { type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [-0.1145, 51.4618] }, properties: { weight: 0.5 } },
  ],
};

const heatmapStyle = {
  heatmapWeight: ['get', 'weight'],
  heatmapRadius: ['interpolate', ['linear'], ['zoom'], 0, 20, 9, 60],
  heatmapColor: [
    'interpolate', ['linear'], ['heatmap-density'],
    0, 'rgba(0,0,255,0)',
    0.5, 'cyan',
    1, 'red',
  ],
};

export default class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{ flex: 1 }}>
        <Camera defaultSettings={{ centerCoordinate: [-0.1276, 51.5074], zoomLevel: 9 }} />
        <ShapeSource id="heatmap-source" shape={features}>
          <HeatmapLayer id="heatmap-layer" sourceID="heatmap-source" style={heatmapStyle} filter={['==', ['literal', 1], ['literal', 0]]}
 />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

If you create a CircleLayer with the same filter, it disappears as expected.

Expected behavior

The filter should be applied to the heatmap - no filters are applied at all.

Notes / preliminary analysis

Initially tested on an older version of RN (0.76.9) but tried in a brand new project and still not working.

Additional links and references

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions