WhoBuilt

Building a full JS deep zoom image viewer

Sep 22, 2022· 46 min· 2.9K views·Watch on YouTube

Speaker

Maxence Harm, co-founder of a SaaS company for construction professionals, presents at React Native EU 2022 with Callstack about building a deep zoom blueprint viewer in React Native.

Why build a custom viewer

Harm weighs the usual advice to reuse existing libraries against the needs of a specific component. Their first version used a pan and zoom image viewer adapted from a React Native Reanimated example. They needed access to the viewport position so users could place a marker precisely beneath a fixed center point.

Why image pyramids fit the requirements

The next version needed to support large raster plans and PDF pages while keeping downloads, rendering, and interaction responsive. Harm explains that image pyramids split an image into tiles across zoom levels, so the viewer can load only the tiles needed for the current viewport. The team set goals that included 60 frames per second and avoiding memory exhaustion on low-end devices.

React Native Maps proof of concept

The team used Leaflet on the web and React Native Maps on mobile to test tiled plans. The proof of concept displayed the pyramid and markers, but the Google logo and map-oriented interaction and coordinate systems made it awkward for their centered-marker workflow. Harm says the team also found the library’s maintenance situation uncertain at the time.

A custom Reanimated tile viewer

The team replaced the map component with a custom viewer based on its earlier pan and zoom implementation, adapting it to position tile layers. Reanimated 2 shared values track scale and zoom, while virtualization limits rendering to visible tiles. The production component lets users navigate large plans and place markers, though some loading is visible.

Remaining work and possible reuse

Harm lists double-tap zoom, animated jumps to coordinates, and bouncy gestures as features still to add. Virtualization could improve, and sending visible-tile and zoom state back to JavaScript can cause frame drops. The component is not open source, though the team may consider releasing it if there is interest.

Takeaways

  • Choose a component library against the exact interaction and data needs of the feature.
  • Image pyramids can keep large plans usable by loading tiles for the current viewport.
  • A map library may display custom tiles well but still impose map-specific coordinates and UX constraints.
  • Virtualize tiles to limit memory use, and keep cross-thread state updates in mind when tuning frame rate.
  • A proof of concept can validate feasibility while exposing library constraints before production integration.

Mentioned in this talk

Search inside this talk

What was claimed 3

  • feature
    Notion: Project management tools for construction professionals, including task management, time planning, cost tracking, communication, reporting, and floor plans
    “It features lots of project management tools”
    YouTube
    Unverified1 source· Talk
  • feature
    Deep Zoom: Loads square image tiles across pyramid levels to support detailed zooming
    “the original file is split into square tiles.”
    YouTube
    Unverified1 source· Talk
  • feature
    Deep Zoom: Viewer virtualizes tiles by computing and displaying only those visible in the viewport
    “we compute the visible tiles and only display those.”
    YouTube
    Unverified1 source· Talk

Related talks