Ionic 2 does not support JS any more so I’m trying to convert the app I’m working on in TS.
But I have a lot of problems.
Basicly my app show a google map with markers and it is working very well in beta 8.
- The map is based on this great tutorial by Josh Morony : Creating an Advanced Google Maps Component in Ionic 2 | Josh Morony
- I’m using the js lib Markerclusterer to … cluster the markers : GitHub - googlearchive/js-marker-clusterer: A marker clustering library for the Google Maps JavaScript API v3.
For the moment I already converted almost all the JS code in my /app directory to TS but I’m facing critical errors that I actually don’t know how to solve
- Despite Josh tutorial is written in TS I have some errors
1.1- To use the Google Maps api callback function “mapInit” : Now I have this error :
TypeScript error: D:/DEV/projets/treizeaccv5/app/pages/map/map.ts(103,20): Error TS2339: Property ‘mapInit’ does not exist on type ‘Window’.
OK 1.1 solved with : (<any>window).mapInit()
1-2 - The connectivity-service does not work any more, now I have this error :
TypeScript error: D:/DEV/projets/treizeaccv5/app/providers/connectivity-service/
connectivity-service.ts(27,36): Error TS2339: Property ‘connection’ does not exi
st on type ‘Navigator’.
TypeScript error: D:/DEV/projets/treizeaccv5/app/providers/connectivity-service/
connectivity-service.ts(29,31): Error TS2304: Cannot find name ‘Connection’.
- I did not find the way to include the markerclusterer JS libary, so I have copied/pasted the code in my ionic page and converted thoses functions in classes. It was working well in JS, but now I dont know how to use this (vital for me) library.
I tryed to install the library through npm (markerclustererplus - npm) and to install the definition file as mentioned in this tutorial : Ionic 2 and External Libraries
Now I have
- A new “markerclustererplus” directory in node_module
- my d.ts file is here : /typings/globals/markerclustererplus/index.d.ts
- I added
/// <reference path="globals/markerclustererplus/index.d.ts" />
in /typings/index.d.ts - I also have /typings/globals/google.maps/index.d.ts for the Google Maps library
But when I put " import {MarkerClusterer} from ‘markerclustererplus’; " in my ionic page I get
ionic $ Error: Cannot find module ‘markerclustererplus’ from ‘D:\DEV\projets\tre
izeaccv5\app\pages\map’
If a kind soul can help me to make progress with these problems I would be very grateful !
Many thanks in advance for your help.