Search code examples
htmlangularnativescriptopenlayersangular-openlayers

Use Openlayers in NativeScript Project


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?


Solution

  • 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.