Utilisation des composants PocketMaps dans Windev ( Pcsoft )
Besoin initial :
Utiliser la cartographie et la navigation en mode Hors-ligne dans une
application WinDev mobile.
Trouver un spécialiste Windev+Javascript
Problématique :
Transposer le code du projet Android dans WinDev mobile (langage Javascript)
Plusieurs projets ont déjà été transposé depuis du JS vers du Windev, mais
jamais aussi complexe.
Un projet WinDev a été débuté ( téléchargement des cartes et affichage Carte )
Fonctions utiles dans le projet Android :
- MapHandler.java
public void init(MapView mapView, String currentArea, File mapsFolder)
public void loadMap(File areaFolder, MapActivity activity)
void loadGraphStorage(final MapActivity activity) {
Différentes techniques ont été tentées :
- Via un champ HTML, mais ne fonctionne bien que lorsque l’on utilise des
fichiers .js, mais les .java ne passent pas bien sans refaire la synthaxe.
- Via un champ Natif, mais tres difficile a debugger lorsque la compilation ne
passe pas.
1. Projet GITHub à transposer
https://github.com/junjunguo/PocketMaps
Free offline maps with routing functions and more ...
This project uses OSM data, Mapsforge-vtm and Graphhopper open source API.
2. Projet Android
On utilise les repository
maven {
url "
https://mvnrepository.com/artifact/com.graphhopper/graphhopper"
}
maven {
url "
https://mvnrepository.com/artifact/org.mapforge/mapsforge-map"
}
3. Projet Windev
Exemple de code qui ne compile pas :
public static void CarteInitialiser( String sNomChampCarte )
{
// Création de la carte
MapView mapView = new MapView(document.getElementById(sNomChampCarte));
//mapView.setClickable(true);
// Map events receiver
//mapView.map().layers().add(new MapEventsReceiver(mapView.map()));
// Map file source
MapFileTileSource tileSource = new MapFileTileSource();
tileSource.setMapFile(new File(areaFolder, currentArea +
".map").getAbsolutePath());
VectorTileLayer l = mapView.map().setBaseMap(tileSource);
}
Rapport d’erreurs
Echec de la création de l'application Android <C:Mes Projets
TestsPocketMaps_POCExeApplication AndroidPocketMaps_POC.apk>.
Ligne de commande : "C:Program FilesJavajdk-10.0.2binjava.exe" -Duser.dir="C:Mes
Projets TestsPocketMaps_POCAndroidgen" "-Dorg.gradle.appname=C:Mes Projets
TestsPocketMaps_POCAndroidgen" -classpath "C:UsersAlanAppDataRoamingPC
SOFT26.0AndroidGradlelibgradle-launcher-5.4.1.jar"
org.gradle.launcher.GradleMain assembleRelease -b "C:Mes Projets
TestsPocketMaps_POCAndroidgenbuild.gradle"
Erreur retournée :
:compileReleaseJavaWithJavac
C:Mes Projets
TestsPocketMaps_POCAndroidgensrccommasocietepocketmaps_pocwdgenGWDCPCOL_Carte_PocketMaps_Android.java:139:
error: cannot find symbol
MapView mapView = new MapView(document.getElementById(sNomChampCarte));
^
symbol: variable document
location: class GWDCPCOL_Carte_PocketMaps_Android
C:Mes Projets
TestsPocketMaps_POCAndroidgensrccommasocietepocketmaps_pocwdgenGWDCPCOL_Carte_PocketMaps_Android.java:148:
error: cannot find symbol
tileSource.setMapFile(new File(areaFolder, currentArea +
".map").getAbsolutePath());
^
symbol: variable areaFolder
location: class GWDCPCOL_Carte_PocketMaps_Android
C:Mes Projets
TestsPocketMaps_POCAndroidgensrccommasocietepocketmaps_pocwdgenGWDCPCOL_Carte_PocketMaps_Android.java:148:
error: cannot find symbol
tileSource.setMapFile(new File(areaFolder, currentArea +
".map").getAbsolutePath());
^
symbol: variable currentArea
location: class GWDCPCOL_Carte_PocketMaps_Android
Note: C:Mes Projets
TestsPocketMaps_POCAndroidgensrccommasocietepocketmaps_pocwdgenGWDFFEN_Main_Mobile.java
uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
> Task :compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at
https://help.gradle.org
BUILD FAILED in 25s
10 actionable tasks: 6 executed, 4 up-to-date