I am new to NativeScript and have knowledge of Angular. I am trying to insert a map to my mobile app with Openlayers. In Angular, in other words HTML, we can create a div
and let openlayer draw the map on it. However, I can't find any equivalent to div in NativeScript, or XML. How should I overcome this?
Asked
Active
Viewed 697 times
-2

zhangjinzhou
- 2,461
- 5
- 21
- 46
1 Answers
2
Unlike Cordova / PhoneGap, NativeScript does not run within WebView. It has a JavaScript runtime which allows you to reuse your web skills not web components. Anything that depends on Browser / HTML Dom can't be used within NativeScript as the UI is purely native here.
If you still want to use Openlayers, you should host a WebView in your application and load your HTML / JavaScript there which can manipulate the map for you. You may also use nativescript-webview-interface to communicate with your NativeScript runtime from your web app running within the WebView.

Manoj
- 21,753
- 3
- 20
- 41
-
Thanks! Another important component of our app is d3 graphs. Since you mentioned nativescript does not support HTML Dom, how do you draw something on the UI? – zhangjinzhou Apr 22 '19 at 06:29
-
You use the native components with native apps. NativeScript itself has a [chart plugin](https://www.npmjs.com/package/nativescript-ui-chart), there are plenty of free / paid libraries available for iOS & Android. Also as I mentioned above, another solution is to load them inside WebView, a lot of mobile apps does that at least in case of charts I have noticed. – Manoj Apr 22 '19 at 06:42