Hi, FYI: NB to TS and Ionic and rusty with Angular!
I’m trying to use a third-party JS (no ts available) file and attempting to implement it “correctly” in Ionic - and so far without any luck.
The JS file resides in ../assets/js/airmap.map.2.2.0.min
. I am trying to call on it in my **airmap.ts**
as follows:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-airmap',
templateUrl: 'airmap.html',
})
export class AirmapPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad AirmapPage');
}
ionViewWillEnter() {
let config = {
"airmap": {
"api_key": "...."
},
"auth0": {
"client_id": "....",
"callback_url": null
},
"mapbox": {
"access_token": '....'
}
};
let map = new Airmap.map(config, { // <---- 'Airmap' - TS ERRORs HERE -----> //
container: 'airspaceMap',
theme: 'standard',
center: [33.238634, -111.7078655],
zoom: '10',
layers: ['airports_commercial', 'national_parks', 'tfrs', 'wildfires'],
/* refer to the docs for a comprehensive list of options */
});
map.on('load', function() {
// set layers
let controlled_airspace_layers = ['class_b', 'class_c', 'class_d', 'class_e0'];
map.setLayers(controlled_airspace_layers);
// add Prohibited Special Use Airspace
map.addLayer('sua_prohibited');
});
map.on('click', function(click) {
map.move(click.lngLat.lat, click.lngLat.lng);
});
}
}
I have tried various routes without any luck ( because I don’t know what I am doing here ) including in my
**app.module.ts**
:
import { Airmap } from '../assets/js/airmap.map.2.2.0.min'
@NgModule({
declarations: [
MyApp,
Airmap,
// LoginPage,
],
…And tried adding it in the index.html
. . .
<!-- Ionic's root component and where the app will load -->
<ion-app></ion-app>
<!--Airmap-->
<script src="assets/js/airmap.map.2.2.0.min.js"></script>
<!-- The polyfills js is generated during the build process -->
<script src="build/polyfills.js"></script>
. . .
So any help with steps and code examples would be greatly appreciated and will go a long ways on me learning this new and awesome framework (for me anyways). Thinx!!