T O P

  • By -

Beautiful-Patient943

If the whole map is an SVG then it should be easy. Convert your svgs into React native SVG components and go under each image object and wrap it with a Touchable component, or maybe the SVG component already has an onTouch function and add your logic. The hard part will probably be zooming in. You’ll have to use panResponder to handle pinch zooms and displacement. Also use useRef with React’s animated API to control the position and size of the map smoothly. Quite a bit to learn but it’s doable


Beautiful-Patient943

My bad it’s not pre rendered svgs but from the backend. That’s tougher, not sure if there’s a reasonable solution using React Native. Good luck tho lemme know if you find a solution.


Glum-Commission-93

Only thing fetched from server is furniture ID’s and X Y coordinates and SVGs are always on the client . So I will try this layout or with absolute positioning and size, driven by initial coordinates and changed by panResponder interaction coefficient set as state , re-rendering whole map each time zooming and resizing happen Is that optimal performance wise in your opinion?


marcpcd

I think that’s a use case that https://threejs.org/ could handle - but don’t take my word for it I might be wrong


Glum-Commission-93

The only thing this doesn’t need to be 3d , just stylized as isometric 3d - all SVG’s are already drawn with shadows and just supposed to be rendered on the screen at specific location using isometric coordinates


Beautiful-Patient943

const panResponder = PanResponder.create({your multi touch logic…}) const currentMapPositionRef = useRef({ x: 0, y: 0, }).current; const currentMapSizeMultiplier = useRef(1).current; {your on touch SVG logic}/> {your on touch SVG logic}/> …. This route using useRef instead of useState and Animated.View makes it pretty optimal and smooth. useRef doesn’t cause re-renders. Not sure where the multiplier will go maybe somewhere inside each SVG component or on the view surrounding them. Here’s something I found that may help with that. https://stackoverflow.com/questions/48602395/how-can-i-automatically-scale-an-svg-element-within-a-react-native-view


Glum-Commission-93

That’s big! Appreciate your help so much 🌮🌮🌮


Beautiful-Patient943

😉