question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clustering is not working with custom styles

See original GitHub issue

I followed the earthquake example, clustering works well with default templates (in MapboxGL.StyleURL), but if i change styleURL to a custom style, all clusters disappear. My current application is built in native code (Swift) still works with this custom style.

default style Simulator Screen Shot - iPhone 11 - 2020-04-23 at 15 03 02

custom style Simulator Screen Shot - iPhone 11 - 2020-04-23 at 15 03 24

This is my code:

<View style={styles.mapContainer}>
      <MapboxGL.MapView
          // can try with https://openmaptiles.github.io/klokantech-basic-gl-style/style-cdn.json
          styleURL="https://my-domain-url/style.json" 
          style={styles.map}
      >
            <MapboxGL.Camera
              centerCoordinate={[146.092859151588556, -38.026307135266585]}
              zoomLevel={4}
              minZoomLevel={0}
              maxZoomLevel={14}
            />
            <MapboxGL.ShapeSource
              id="trackClustersSource"
              shape={trackCenters}
              cluster
              clusterRadius={50}
              clusterMaxZoom={14}
            >
                <MapboxGL.SymbolLayer
                  id="pointCount"
                  style={layerStyles.clusterCount}
                />
                <MapboxGL.CircleLayer
                  id="circleClustersLayer"
                  belowLayerID="pointCount"
                  filter={['has', 'point_count']}
                  style={layerStyles.clusteredPoints}
                />
            </MapboxGL.ShapeSource>
     </MapboxGL.MapView>
</View>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mfazekascommented, Apr 29, 2020

import React from 'react';
import {
  MapView,
  ShapeSource,
  SymbolLayer,
  CircleLayer,
  Camera,
} from '@react-native-mapbox-gl/maps';
import {featureCollection, point, feature, lineString} from '@turf/helpers';

const diff = 0.01;

const shape = featureCollection([
  point([146.092859151588556, -38.026307135266585], {}),
  point([146.092859151588556 + diff, -38.026307135266585], {}),
  point([146.092859151588556, -38.026307135266585 + diff], {}),
  point([146.092859151588556, -38.026307135266585 + 2 * diff], {}),
  point([146.092859151588556, -38.026307135266585 + 3 * diff], {}),
]);

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView
        style={{flex: 1}}
        styleURL={
          'https://newtracstileserver.azurewebsites.net/styles/newtracs-master/style.json'
        }>
        <Camera
          centerCoordinate={[146.092859151588556, -38.026307135266585]}
          zoomLevel={8}
        />
        <ShapeSource
          shape={shape}
          cluster
          clusterRadius={50}
          clusterMaxZoom={14}>
          {true && (
            <SymbolLayer
              id="pointCount"
              style={{
                textField: 'Foo',
                textSize: 12,
                textFont: ['Noto Sans Regular'],
              }}
            />
          )}
          <CircleLayer
            id="circles"
            style={{
              circleColor: 'red',
              circleRadius: 5,
            }}
          />
        </ShapeSource>
      </MapView>
    );
  }
}

This one seems to work for me, the issue in your example was that SymbolLayer uses fonts that not available in the custom style pls specify a font that’s in the style.

I’ll try to add some warnings for such cases. On iOS MGLLoggingConfiguration can be used like this:

    MGLLoggingConfiguration* config = [MGLLoggingConfiguration sharedConfiguration];
    config.loggingLevel = MGLLoggingLevelWarning;
    config.handler = ^(MGLLoggingLevel loggingLevel, NSString *filePath, NSUInteger line, NSString *message) {
        if ([message containsString:@"Failed to load glyph range"]) {
            RCTLogWarn(@"Mapbox missing glyph: %@", message);
        }
    };
com.mapbox.mapboxsdk.log.Logger.setVerbosity(Logger.LogLevel.WARN)
com.mapbox.mapboxsdk.log.Logger.setLoggerDefinition(new LoggerDefinition {
..
})
0reactions
ivansolobear-omnicommented, Dec 14, 2022

thanks so much for this thread , I just spent whole 2 days on this error, cuz I couldn’t even figure out how to search for this. Please add an error in case the font could not be imported as I could not find any indication about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clustering is not working with custom styles #839 - GitHub
My current application is built in native code (Swift) still work... ... Clustering is not working with custom styles #839.
Read more >
Unable to apply custom icons for clustering in google maps ...
According to this and this, you can customise cluster icons by first converting the cluster icon to a marker via the MarkerClusterer 's ......
Read more >
Why setStyle does not work for point geometry from cluster?
1 Answer. Save this answer. Show activity on this post. Cluster features are regenerated every time the view changes, any setting you make...
Read more >
Clustering is not supported on this version of ArcGIS Server ...
You are attempting to share a clustered feature layer as a map image layer or web feature layer to a version of ArcGIS...
Read more >
8 Ways to Style Point Clusters on the Web - Esri
This simply communicates where data points exist with no additional ... Creating any custom renderer for clusters requires you to define at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found