maplibre-rs icon indicating copy to clipboard operation
maplibre-rs copied to clipboard

Render to views on Android/iOS

Open maxammann opened this issue 3 years ago • 2 comments

At some point we want to render to specific android and ios views and not to the whole screen. This is currently unsupported by winit.

Sadly it is not enough to render to a surface provided by the NDK/UIKit/AppKit. We also need to hook into the input handlers of iOS and Android. Maybe we should think about removing the complete winit dependency and handle all gestures in the corresponding SDKs and control the maplibre view from there. This means that the input handlers would be written in Swift/Kotlin/JavaScript instead of Rust.

iOS:

Difficult because winit is bound to the main UIApplicationView

  • https://github.com/rust-windowing/winit/blob/cbba00d3600fa49394dac8538be17a438031622a/src/platform_impl/macos/window.rs#L388
  • https://github.com/rust-windowing/winit/issues/802
  • https://github.com/rust-windowing/winit/issues/1281

Android:

Difficult because winit is bound to the main NativeActivity

  • https://github.com/rust-windowing/android-ndk-rs/issues/262
  • https://github.com/rust-windowing/winit/blob/cbba00d3600fa49394dac8538be17a438031622a/src/platform_impl/android/mod.rs#L783
  • use JNA instead of JNI? https://github.com/java-native-access/jna

Gestures

  • Here is now pint-to-zoom is handlen on Android: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ScaleGestureDetector.java

maxammann avatar Apr 23 '22 09:04 maxammann

Take a look at #91 when thinking about adding gesture/input handling.

maxammann avatar Jun 20 '22 13:06 maxammann