Vishal Prajapati
Vishal Prajapati

Reputation: 1

Geting Error "mapbox::util::bad_variant_access" while cluster is enable for the "Point" and "Polygon" geo json data

Mapbox Implementation

Mapbox

Mapbox Version

default

React Native Version

0.71.8

Platform

iOS, Android

@rnmapbox/maps version

10.1.31

Sample Code

import MapboxGL, { MapView } from "@rnmapbox/maps";
import React from "react";

const MapScreen = () => {
  const GEO_JSON = [
    //link attched in description
  ];

  return (
    <MapView requestDisallowInterceptTouchEvent style={{ flex: 1 }}>
      <MapboxGL.ShapeSource
        id="hangoutMarkers"
        onPress={() => {}}
        cluster
        clusterRadius={50}
        clusterMaxZoomLevel={16}
        shape={GEO_JSON}
      >
        <MapboxGL.SymbolLayer
          id="singlePoint"
          filter={["==", ["geometry-type"], "Point"]}
          style={{
            iconImage: ["get", "icon"],
            iconSize: 0.2,
            iconAllowOverlap: false,
          }}
        />
        <MapboxGL.SymbolLayer
          filter={["==", ["geometry-type"], "Point"]}
          id="pointCount"
          style={{
            textField: [
              "format",
              ["concat", ["get", "point_count"], "\n"],
              {},
              ["concat"],
              { "font-scale": 0.8 },
            ],
            textSize: 12,
            textPitchAlignment: "map",
          }}
        />
        <MapboxGL.CircleLayer
          id="clusteredPoints"
          belowLayerID="pointCount"
          filter={["has", "point_count"]}
          // style={layerStyles.clusteredPoints}
        />
        <MapboxGL.FillLayer
          id="polygonFillLayer"
          filter={["==", ["geometry-type"], "Polygon"]}
          style={{
            fillColor: "black",
          }}
        />
        <MapboxGL.LineLayer
          id="polygonLineLayer"
          filter={["==", ["geometry-type"], "Polygon"]}
          style={{
            lineColor: "black",
            lineWidth: 2,
            lineDasharray: [1, 0],
          }}
        />
      </MapboxGL.ShapeSource>
    </MapView>
  );
};

export default MapScreen


Geo Json link https://drive.google.com/file/d/17vgyPMDGxT_4uIVBndTXmh0WfIDb3vZn/view?usp=sharing

Lib used: "@mapbox/mapbox-sdk": "^0.16.1" "@rnmapbox/maps": "^10.1.31"

When multi type features is there (Point and Polygon) in GEO JSON and clustering is enable from the MapboxGL.ShapeSource then App going to crash and giving error for the "bad variant access". When I am commenting the clustering props in the MapboxGL.ShapeSource then is working and show the Point and Polygon view on the Map view.

Expecting : Clustering should work with the "Point" and "Polygon".

Upvotes: 0

Views: 21

Answers (0)

Related Questions