Slowness when creating LineString
See original GitHub issueProblem Description:
- As the center of the map changes, I set the coordinate of the new center to the LineString component. But LineString changes very slowly.
This is video url for problem : https://vimeo.com/724430478
My Code:
import React, { useRef, useState } from 'react';
import { Pressable, View } from 'react-native';
//Third Party
import MapboxGL from '@rnmapbox/maps';
//Styles
import styles from './style';
import Icon from '@components/Icon';
MapboxGL.setAccessToken('NOT_REQUIRED');
const Maps = () => {
const [points, setPoints] = useState([]);
const [mapCenter, setMapCenter] = useState([]);
const camRef = useRef(null);
const mapRef = useRef(null);
const RouteLine = () => {
return (
<MapboxGL.ShapeSource
id="routeLine"
shape={{
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: points,
},
},
],
}}>
<MapboxGL.LineLayer
id="lines"
style={{
lineColor: 'blue',
}}
/>
</MapboxGL.ShapeSource>
);
};
const LastLine = () => {
return (
<MapboxGL.ShapeSource
id="LastLineShape"
shape={{
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: [points?.[points?.length - 1] || [], mapCenter],
},
},
],
}}>
<MapboxGL.LineLayer
id="preLines"
style={{
lineColor: 'blue',
lineDasharray: [10, 5],
}}
/>
</MapboxGL.ShapeSource>
);
};
const setNewPoint = async () => {
const point = await mapRef?.current?.getCenter();
setPoints(x => [...x, point]);
};
const changeMapRagion = val => {
setMapCenter(val?.geometry?.coordinates);
};
return (
<View style={styles.container}>
<MapboxGL.MapView
ref={mapRef}
style={styles.map}
logoEnabled={false}
attributionEnabled={false}
onRegionIsChanging={changeMapRagion}
// onRegionDidChange={changeMapRagion}
styleURL={'https://***.json'}>
<MapboxGL.Camera ref={camRef} centerCoordinate={[35, 39]} zoomLevel={3.5} animationDuration={1200} />
<RouteLine />
{points?.length > 0 && <LastLine />}
</MapboxGL.MapView>
<View style={styles.target}>
<Icon name="target : materialcomm" size={40} />
</View>
<Pressable style={styles.plusPointPress} onPress={setNewPoint} hitSlop={8}>
<Icon name="plus : feather" size={40} color="#fff" />
</Pressable>
</View>
);
};
export default Maps;
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
ST_Difference on linestrings and polygons slow and fails
I am trying to create a new table of linestrings with their existing attribution that are "different" to some polygons and am struggling...
Read more >Improve performance of LineString creation, that currently is ...
I don't think your approach is that bad - creating a large number of shapely LineStrings from 1e6 points is just slow.
Read more >QST: clip runs so slow · Issue #2593 · geopandas ... - GitHub
I am trying to clip linestrings from polygons. Both input data are quite large e.g. Polygons 86 million and linestring 1 million. I...
Read more >LINESTRING | CockroachDB Docs
A LINESTRING is a collection of Points that are "strung together" into one geometric object. A LineString can be used to represent an...
Read more >The Shapely User Manual — Shapely 2.0.0 documentation
Creates polygons from a source of lines, returning the polygons and leftover geometries. The source may be a MultiLineString, a sequence of LineString...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
react-native-maps. Would prefer this library and mapbox in general, but had some road blocks that held things up.
What lib did you switch to?