Is it possible to use NativeScript's WebView as a WebMap in a hybrid app?

Viewed 325

For example, the WebView will load a local map.html

This map.html will have a map loaded on it via main-page.js, so this JS file will by both Native and WebView elements.

On top of this WebView map will be a floating native button that pans the map to your location.

Is this flow possible in NativeScript? A JS file that controls both native elements and a WebView

If possible, how is this integration achieved? Does it need some complex setup?

Is this flow recommended? Would it cause any major performance issues?

1 Answers

It's absolutely possible to have a WebView and place native button over it. But you can't control everything within single JS file, you have to use nativescript-webview-interface plugin to interact between WebView and native functions.

If you ask about performance, WebView is never great not just with NativeScript but in general. Imagine how you would feel when using your Google Maps within Chrome of your Android, that's going to be the user experience. Almost every map apis got native libraries for iOS & Android, at least {N} has plugins for Google Map and Mapbox, so I would recommend that.

Related