How to use geoman-io with ngx-leaflet - leaflet

I am trying to use geoman-io plugin (https://github.com/geoman-io/leaflet-geoman) in ngx-leaflet application. I've found this post: Integrate EasyButton, Geoman with ngx-leaflet , but the only solution provided in this post, that works for me, is to use bracket notation like that:
map["pm"]["addControls"]({position: 'topleft'});
I guess that's not the best way to do this. So my question is how to properly use geoman-io in ngx-leaflet?
When i tried exactly these steps, it doesn't work, because at map.pm.addControls({...}) i get error
Property 'pm' does not exist on type 'Map'
Steps:
npm i #geoman-io/leaflet-geoman-free
Import geoman in the component import '#geoman-io/leaflet-geoman-free';
In angular.json in "build" section import geoman styles:
"styles": [
"src/styles.scss",
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/#geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css"
],
my component:
import { BaseIconOptions, geoJSON, Bounds, CRS, Icon, icon, IconOptions, imageOverlay, latLng,
LatLngBounds, LatLngBoundsExpression, layerGroup, Map, marker, point, polyline, tileLayer } from 'leaflet';
import * as L from 'leaflet';
import 'leaflet-rotatedmarker';
import '#geoman-io/leaflet-geoman-free';
#Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent {
...
onMapReady(map: Map) {
map.pm.addControls({
position: 'topleft',
drawMarker: false
});
}
}
My package.json file:
"dependencies": {
"#angular/animations": "~10.2.0",
"#angular/cdk": "^10.2.7",
"#angular/common": "~10.2.0",
"#angular/compiler": "~10.2.0",
"#angular/core": "~10.2.0",
"#angular/flex-layout": "^10.0.0-beta.32",
"#angular/forms": "~10.2.0",
"#angular/material": "^10.2.7",
"#angular/platform-browser": "~10.2.0",
"#angular/platform-browser-dynamic": "~10.2.0",
"#angular/router": "~10.2.0",
"#asymmetrik/ngx-leaflet": "^8.1.0",
"#fortawesome/angular-fontawesome": "^0.7.0",
"#geoman-io/leaflet-geoman-free": "^2.7.0",
"#types/leaflet": "^1.5.19",
"#types/leaflet-rotatedmarker": "^0.2.1",
"leaflet": "^1.7.1",
"leaflet-rotatedmarker": "^0.2.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.1002.0",
"#angular/cli": "~10.2.0",
"#angular/compiler-cli": "~10.2.0",
"#types/node": "^12.11.1",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
If i change the the onMapReady function to onMapReady(map: L.Map) , it throws the same error. Thanks for help!

For me it works with the dirty type any:
onMapReady(map: any)

Related

ngx-image-cropper: Doesn't work into ionic modal view

I have a problem using ngx-image-cropper into an ionic modal view.
It's a headache.
If a call a view normally by route, it works.
I look for a solution or at least some one with the problem and nothing.
I am using:
"dependencies": {
"#angular/common": "^14.0.0",
"#angular/core": "^14.1.0",
"#angular/forms": "^14.0.0",
"#angular/platform-browser": "^14.0.0",
"#angular/platform-browser-dynamic": "^14.0.0",
"#angular/router": "^14.0.0",
"#capacitor/android": "3.6.0",
"#capacitor/app": "1.1.1",
"#capacitor/camera": "^1.3.1",
"#capacitor/core": "3.6.0",
"#capacitor/device": "^1.1.2",
"#capacitor/haptics": "1.1.4",
"#capacitor/ios": "3.6.0",
"#capacitor/keyboard": "1.2.3",
"#capacitor/status-bar": "1.0.8",
"#capacitor/storage": "^1.2.5",
"#capacitor/toast": "^1.0.8",
"#ionic-native/call-number": "^5.36.0",
"#ionic/angular": "^6.2.0",
"#ionic/pwa-elements": "^3.1.1",
"call-number": "^1.0.1",
"hammerjs": "^2.0.8",
"ngx-image-cropper": "^6.2.2",
"rendered-country-flags": "^1.2.1",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "^14.0.0",
"#angular-eslint/builder": "~13.0.1",
"#angular-eslint/eslint-plugin": "~13.0.1",
"#angular-eslint/eslint-plugin-template": "~13.0.1",
"#angular-eslint/template-parser": "~13.0.1",
"#angular/cli": "^14.0.0",
"#angular/compiler": "^14.0.0",
"#angular/compiler-cli": "^14.0.0",
"#angular/language-service": "^14.0.0",
"#capacitor/cli": "3.6.0",
"#ionic/angular-toolkit": "^6.1.0",
"#ionic/lab": "3.2.13",
"#types/jasmine": "~3.6.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"#typescript-eslint/eslint-plugin": "5.3.0",
"#typescript-eslint/parser": "5.3.0",
"eslint": "^7.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"typescript": "~4.7.3"
},
Into Ionic 6.20.0
I encapsulate the cropper call into a service that manages camera or gallery photo and pass it to cropper modal view.

Ionic native calendar TypeError: Object(...) is not a function

I've just installed the ionic native calendar plugin for phone gap, based on the instructions here: https://ionicframework.com/docs/v3/native/calendar/
When I call anything like hasWritePermission() I get the following error:
index.js:685 Uncaught TypeError: Object(...) is not a function
at index.js:685
at Module../node_modules/#ionic-native/calendar/index.js (index.js:888)
at __webpack_require__ (bootstrap:83)
at Module../src/app/modals/event-detail-modal/event-detail-modal.component.ts (main.js:2401)
at __webpack_require__ (bootstrap:83)
at Module../src/app/app.module.ts (app.component.ts:13)
at __webpack_require__ (bootstrap:83)
at Module../src/main.ts (main.ts:1)
at __webpack_require__ (bootstrap:83)
at Object.0 (main.ts:12)
I'm using ionic 4 and angular 7, I'm wondering if this is down to unsupported dependencies? If it is, is there a more up to date plugin I can use, or am I doing something wrong here?
CODE: (addToCalendar method at the bottom)
import { Component, OnInit } from '#angular/core';
import {ModalController, NavParams} from "#ionic/angular";
import {ActivatedRoute, ActivatedRouteSnapshot} from "#angular/router";
import {Calendar} from "#ionic-native/calendar";
interface EventsInterface {
title: string;
startTime: Date;
endTime: Date;
ID: number;
categoriesString: string;
description: string;
recurring: boolean;
recurFrequency: string;
thumbnail: string;
}
#Component({
selector: 'app-event-detail-modal',
templateUrl: './event-detail-modal.component.html',
styleUrls: ['./event-detail-modal.component.scss'],
})
export class EventDetailModalComponent implements OnInit {
/**
*
*/
public event: EventsInterface = null;
/**
*
* #param modalController
* #param navParams
*/
constructor(private calendar: Calendar,private modalController: ModalController, private navParams: NavParams) { }
/**
*
* #param route
*/
ngOnInit() {
// get the event
this.event = <EventsInterface>this.navParams.get('event');
console.log(this.event);
}
/**
*
*/
dismiss(){
return this.modalController.dismiss({
'dismissed':true
});
}
addToCalendar(event: EventsInterface){
this.calendar.hasWritePermission().then((resp: any)=>{
console.log(resp)
}).catch((resp: any) =>{
console.log(resp);
});
}
}
As you can see, I've done very little so far execpt install the plugins and setup a simple promise catch...
EDIT
p
It appears to be related to the wrong versions of some libraries, when installing with nom it warns:
npm WARN #ionic-native/calendar#4.20.0 requires a peer of #ionic-native/core#^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN #ionic-native/calendar#4.20.0 requires a peer of rxjs#^5.5.11 but none is installed. You must install peer dependencies yourself.
The problem with this is the rest of the app is using ionic native 5.0.0 and rxjs 6.5.1 and for some reason the calendar component won't work with these newer versions?
Here is the package file:
{
"name": "V3",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.15",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#ionic-native/calendar": "^4.20.0",
"#ionic-native/core": "^5.0.0",
"#ionic-native/in-app-browser": "^5.12.0",
"#ionic-native/native-page-transitions": "^5.8.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.1.0",
"#ionic/storage": "^2.2.0",
"#types/jquery": "^3.3.31",
"chart.js": "^2.8.0",
"cordova-ios": "4.5.5",
"cordova-plugin-calendar": "^5.1.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-inappbrowser": "^3.1.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^3.2.0",
"core-js": "^2.5.4",
"intl": "^1.2.5",
"ion4-calendar": "^3.0.4-beta.17",
"ionic2-calendar": "^0.5.2",
"jquery": "^3.4.1",
"moment": "^2.24.0",
"ng2-file-upload": "^1.3.0",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "~7.3.8",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.5.1",
"#types/node": "~12.0.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-sqlite-storage": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-calendar": {
"CALENDAR_USAGE_DESCRIPTION": " ",
"CONTACTS_USAGE_DESCRIPTION": " "
}
},
"platforms": [
"ios"
]
}
}

Error: “Unresolved function or method present()” when using LoadingController

ISSUE:
When I use the LoadingController in my project, I see the following error: "Unresolved function or method present()"
Here is the screenshot code that I have in my file:
As we can see from the screenshot, there are 2 pieces of code that show the same error. The code from lines: 51-61 are a direct copy of the code from the ionic documentation that can be seen under Usage
The code from lines: 63-69 are the trimmed down and basic version of the code and for testing purposes await is removed in front of the loading.present();. Yet it throws the same error as the original code above.
GOAL:
What can we do to fix the issue so that Intellij Idea (IDE) stops complaining about the same?
Following is the info from my package.json:
{
"name": "gf",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "~8.1.2",
"#angular/compiler": "~8.1.2",
"#angular/core": "~8.1.2",
"#angular/forms": "~8.1.2",
"#angular/platform-browser": "~8.1.2",
"#angular/platform-browser-dynamic": "~8.1.2",
"#angular/router": "~8.1.2",
"#ionic-native/core": "^5.0.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.7.1",
"#ionic/storage": "^2.2.0",
"cordova-sqlite-storage": "^3.2.1",
"core-js": "^2.5.4",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/architect": "~0.801.2",
"#angular-devkit/build-angular": "~0.801.2",
"#angular-devkit/core": "~8.1.2",
"#angular-devkit/schematics": "~8.1.2",
"#angular/cli": "~8.1.2",
"#angular/compiler": "~8.1.2",
"#angular/compiler-cli": "~8.1.2",
"#angular/language-service": "~8.1.2",
"#ionic/angular-toolkit": "~2.0.0",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-sqlite-storage": {}
}
}
}
No sure it is the right way to do it but i managed to Intellij to stop whining
return (<any>loading).present();

"ERROR in src\app\app.module.ts(60,22): Error during template compile of 'AppModule' " while building ionic app to ios --prod using cordova

I am trying to deploy my ionic app to appstore. But I cant able to build this app to --prod. There is no error while deploying for test build. Please help me to fix this.
I was working with ionic 3 framework. I created a calendar app. This is my first app so I have no idea to fix this. I am getting error while running the following command
ionic cordova build ios --prod.
Here is my app module
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { RouteReuseStrategy } from '#angular/router';
import { IonicModule, IonicRouteStrategy } from '#ionic/angular';
import { SplashScreen } from '#ionic-native/splash-screen/ngx';
import { StatusBar } from '#ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '#angular/common/http';
import { IonicStorageModule, Storage } from '#ionic/storage';
import { JwtModule, JWT_OPTIONS, JwtHelperService } from '#auth0/angular-jwt';
import { HTTP } from '#ionic-native/http/ngx';
import { ReactiveFormsModule, FormsModule } from '#angular/forms';
import { CommonModule } from '#angular/common';
import { LoginPage } from './login/login.page';
import { HomePage } from './home/home.page';
import { UpdateEventPage } from './home/update-event/update-event.page';
import { AddMembersComponent } from './home/add-members/add-members.component';
import { ProfilePage } from './profile/profile.page';
import { NgCalendarModule } from 'ionic2-calendar';
import { IonicSelectableModule } from 'ionic-selectable';
export function jwtOptionsFactory(storage) {
return {
tokenGetter: () => {
return storage.get('access_token');
},
whitelistedDomains: ['82.165.76.209:57', 'localhost:8100']
}
}
#NgModule({
declarations: [AppComponent, LoginPage, HomePage, UpdateEventPage, AddMembersComponent, ProfilePage],
entryComponents: [UpdateEventPage, AddMembersComponent],
imports: [
BrowserModule,
IonicModule.forRoot(),
IonicStorageModule.forRoot(),
HttpClientModule,
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
NgCalendarModule,
IonicSelectableModule,
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [Storage],
}
}),
AppRoutingModule,
],
providers: [
StatusBar,
SplashScreen,
JwtHelperService,,
HTTP,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
This is my package json dependencies
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.2",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#auth0/angular-jwt": "^2.1.0",
"#capacitor/android": "^1.0.0-beta.19",
"#capacitor/cli": "1.0.0-beta.19",
"#capacitor/core": "1.0.0-beta.19",
"#ionic-native/core": "^5.0.0",
"#ionic-native/http": "^5.5.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.5.0",
"#ionic/angular": "^4.1.0",
"#ionic/pro": "2.0.4",
"#ionic/storage": "^2.2.0",
"cordova-android": "8.0.0",
"cordova-ios": "5.0.1",
"cordova-plugin-advanced-http": "2.0.9",
"cordova-plugin-file": "6.0.1",
"cordova-sqlite-storage": "3.2.0",
"core-js": "^2.5.4",
"ionic-selectable": "^4.4.0",
"ionic2-calendar": "^0.5.2",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.13.8",
"#angular-devkit/build-angular": "~0.13.8",
"#angular-devkit/core": "~7.3.8",
"#angular-devkit/schematics": "~7.3.8",
"#angular/cli": "~7.3.8",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.5.1",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~10.14.2",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "~3.1.6"
},
I am getting the following error.
ERROR in src\app\app.module.ts(60,22): Error during template compile of 'AppModule'
Expression form not supported.
[ERROR] An error occurred while running subprocess ng.
On line 60 you have a typo:
JwtHelperService,,
Change this to:
JwtHelperService,

RxJS module give error after update. how to solve?

In my angular 5 project. My imports have been producing weird errors that I cant remember having a few days ago. For the import here below it says: "module ...rxjs/observable has no exported member observable".
import { Observable } from 'rxjs/Observable';
I did not have this before.
Funny thing is however, the angular website, including the functionality with the observable, works just fine
Here is my package.json:
"private": true,
"dependencies": {
"#angular-devkit/core": "0.0.29",
"#angular/animations": "^5.2.0",
"#angular/cdk": "^5.2.5",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/material": "^5.2.0",
"#angular/material-moment-adapter": "^5.2.5",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"bootstrap": "^4.0.0",
"core-js": "^2.4.1",
"jsonwebtoken": "^8.2.0",
"moment": "^2.20.1",
"moment-duration-format": "^2.2.2",
"npm": "^5.6.0",
"rxjs": "^5.5.12",
"zone.js": "^0.8.19"
},
Unfortunately, I do not know how to solve the import problem. However, I think it might be worth mentioning that I experienced a similar issue when updating to the latest version for Angular 6, that is to say rxjs 6.3.0. So I downgraded to 6.2.1, which made the import errors go away.