react-map-gl
react-map-gl copied to clipboard
Map chokes when drawing more than 5-10 markers
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>
)
Can you check your trace stack and see which line is triggering the assert error?
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!