|
PROFESSIONAL NEWSGROUPS WINDEV, WEBDEV and WINDEV Mobile |
| | | | | |
Manage Map Control in JAVA |
Started by Antonino Neri, Jan., 16 2017 5:13 PM - 8 replies |
| |
| | | |
|
| |
Posted on January, 16 2017 - 5:13 PM |
Hi guys,
I would like to know how I can manage a MAP CONTROL, in an Android app, using JAVA instead of WL functions that are limited and do not fulfill my needs.
I would like to start with something really simple like adding a marker on a map so I try this code:
import android.support.v4.app.FragmentActivity; import android.os.Bundle; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions;
public static void InitializeGoogleMap() { GoogleMap map = getView("MAP_EVENTS"); // Add a marker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); map.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); map.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
but when I compile the app I get an error on the very first line: GoogleMap map = getView("MAP_EVENTS").
Does anyone know how this can be done?
Thank you all.
Kindest Regards, Antonino |
| |
| |
| | | |
|
| | |
| |
Posted on October, 10 2017 - 8:29 AM |
Hi,
Maybe this code will help for anyone whose trying to customise Google map. This is just a sample but it works !!!
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.Marker; import android.widget.Toast;
public static void CustomMap() { MapView mapView = (MapView) getView("CARTE_Accueil"); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { LatLng PARIS = new LatLng(48.858093, 2.294694); //ajoute un marker sur Paris googleMap.addMarker(new MarkerOptions().title("Paris").position(PARIS)); //centre la google map sur Paris (avec animation de zoom) googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(PARIS, 15)); googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Toast.makeText(getContexteApplication(),marker.getTitle(),Toast.LENGTH_LONG).show(); } }); } }); } |
| |
| |
| | | |
|
| | |
| |
Registered member 20 messages Popularité : +1 (1 vote) |
|
Posted on October, 11 2017 - 1:29 PM |
Hi Philippe
I am new in Windev Mobile/Java and I tried to use your precedent code.
I have created a window with a map "CARTE_Accueil". I have create a global procedure (java) with your code but how I can use this code to display a map?
Till now, in Windev Mobile I have succeeded to display a map with some markers
POUR i = 1 _A_ TableOccurrence(TABLE_Adresse) SI PAS (TABLE_Adresse.COL_Latitude[i] = 0 ET TABLE_Adresse.COL_Longitude[i] = 0) ALORS nPos..Latitude = TABLE_Adresse.COL_Latitude[i] nPos..Longitude = TABLE_Adresse.COL_Longitude[i] CarteAffichePosition(CARTE_Points, nPos) tabMMark[i]..Position = nPos CarteAjouteMarqueur(CARTE_Points, tabMMark[i]) FIN FIN CARTE_Points..Zoom = zoomAdapteTaille My code is displaying a map but I need something else : when user moves or enlarges the map, I want to obtain the coordinates of the markers which are still visible in the map.
With Windev Mobile I didn't succeed and I thought that I could use Java but I don't know from where to start.
Thanks for any advice
-- Issa Bej |
| |
| |
| | | |
|
| | |
| |
Registered member 2,574 messages Popularité : +222 (260 votes) |
|
Posted on October, 11 2017 - 1:59 PM |
Hi Issa,
You just have to call the procedure customMap() somewhere in your code, when the window is initializing for exemple.
-- Cordialement,
Philippe SAINT-BERTIN Géode Informatique |
| |
| |
| | | |
|
| | |
| |
Registered member 20 messages Popularité : +1 (1 vote) |
|
Posted on October, 11 2017 - 2:52 PM |
Thank you, Philippe!
I have already tried as you said. I have received error
L'appel de code natif n'est pas disponible. Code erreur : 1185 Niveau : erreur fatale
After that I saw an answer from Fabrice (Harrari)
you are in test mode...
Test mode is a SIMULATION of the android system, but does NOT include a JAVA engine (there is no java complation before the simulation starts)...
therefore, anything in java can be test only after compiling, on a real android hardware and I tried to generate the application without including any files or libraries. I have filled only my google API key. the error is :
Message d'erreur système : The parameter is incorrect.
----- Sous-erreur n°1 ----- Echec de la création de l'application Android .
Ligne de commande : assembleDebug -b "F:\Mes Projets 22 WindevMobile\Mon_ProjetTestCarte\Android\Generation\build.gradle"
Erreur retournée :
Do you have any idea about what is not correct? Thanks a lot
-- Issa Bej |
| |
| |
| | | |
|
| | |
| |
Registered member 2,574 messages Popularité : +222 (260 votes) |
|
Posted on October, 11 2017 - 4:25 PM |
Sorry no idea...
-- Cordialement,
Philippe SAINT-BERTIN Géode Informatique |
| |
| |
| | | |
|
| | |
| |
Registered member 2,574 messages Popularité : +222 (260 votes) |
|
Posted on October, 12 2017 - 2:13 PM |
You must have at least these permissions:
and these functionalities:
-- Cordialement,
Philippe SAINT-BERTIN Géode Informatique |
| |
| |
| | | |
|
| | |
| |
Registered member 20 messages Popularité : +1 (1 vote) |
|
Posted on October, 12 2017 - 3:21 PM |
Hi Philippe!
Thank you for answer.
I have found a solution here,
https://forum.pcsoft.fr/en-US/pcsoft.fr.windevmobile/28657-execution-gradle-28668/read.awp I have replaced version of Gradle.
And after this, it was necessary also to enable in Google Api Console "Google API Android Maps" and now everything it's ok. My first test worked .
Best regards
-- Issa Bej |
| |
| |
| | | |
|
| | |
| |
Registered member 2,574 messages Popularité : +222 (260 votes) |
|
Posted on October, 12 2017 - 4:16 PM |
On the other hand you can't use every methods of a class. For example you can't use the setTag or getID method of Marker class. I have an error
error: cannot find symbol import com.google.android.gms.maps.model.MapStyleOptions; symbol: class MapStyleOptions location: package com.google.android.gms.maps.model
error: cannot find symbol appelProcedureWL("FEN_Menu.pl_SetIDMarqueur",marqueur.getID(),Integer.parseInt(Valeurs[3])); ^ symbol: method getID() location: variable marqueur of type Marker
error: cannot find symbol Toast.makeText(getContexteApplication(),String.valueOf(appelProcedureWL_int("FEN_Menu.pl_GetIDMarqueur",marker.getID))),Toast.LENGTH_LONG).show(); symbol: method getID() location: variable marker of type Marker
3 errors FAILED
Waiting for PC Soft to tell me if it's possible or not. If not then I switch to Xamarin
-- Cordialement,
Philippe SAINT-BERTIN Géode Informatique |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|