react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

Map chokes when drawing more than 5-10 markers

Open shuoch opened this issue 8 years ago • 2 comments

I'm getting the following assertion error whenever I try to render more than 5-10 markers

assert.js?5fb0:195 Uncaught AssertionError {name: "AssertionError", actual: false, expected: true, operator: "==", message: "false == true", …}

I think this error is related to #195 , but I am not accessing either protected variables viewport.isDragging, viewport.startDragLngLat. All I'm doing is displaying multiple markers.

Here's my code for context

<ReactMapGL
            {...viewport}
            mapboxApiAccessToken={mapglToken}
            onViewportChange={this.updateViewport}
            ref={(node) => { this.map = node; }}
          >
            {this.renderNavControl()}
            {locations.map((location, idx) => wrappedMarker(location, idx, this.focusLocation))}
          </ReactMapGL>
const wrappedMarker = (location, idx, focusLocation) => (<Marker
  key={idx}
  latitude={parseFloat(location[15])}
  longitude={parseFloat(location[14])}
  offsetLeft={-10}
  offsetTop={-10}
  captureClick
>
  <Icon
    onClick={focusLocation(location)}
    type='environment-o'
    style={{
      fontSize: '20px',
      color: 'black'
    }}
  />
</Marker>
);
  renderNavControl = () => (
    <div style={{ position: 'absolute', left: '10px', top: '10px' }}>
      <NavigationControl onViewportChange={this.updateViewport} />
    </div>
  )

shuoch avatar Apr 30 '18 21:04 shuoch

Can you check your trace stack and see which line is triggering the assert error?

Pessimistress avatar May 01 '18 18:05 Pessimistress

The stack trace was completely unhelpful, but my coworker managed to find the source of the issue was in our data. It turns out location[15], location[14] in rare occasions are null. Causing those assertion errors. Thanks!

shuoch avatar May 01 '18 18:05 shuoch