IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API standards et tierces Android Discussion :

Problème affichage Map google


Sujet :

API standards et tierces Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2013
    Messages
    40
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2013
    Messages : 40
    Par défaut Problème affichage Map google
    Slt a tous !!!

    J'essaye de créer une application sous android qui permet de se géolocaliser par le wifi ou le GPS.

    Pour l'instant je gère uniquement la position par GPS (mais la n'est pas le problème).

    Lorsque je lance mon application sur mon téléphone (Nexus 5) la map google ne s'affiche pas. J'ai le message suivant qui apparait "the provider network is now disabled". (par contre j'ai bien le cadre de la map avec le quadrillage)

    MainActivity.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    package com.example.localisation;
     
    import android.location.Location;
    import android.location.LocationListener;
    import android.location.LocationManager;
    import android.location.LocationProvider;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.Menu;
    import android.widget.Toast;
     
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapActivity;
    import com.google.android.maps.MapController;
    import com.google.android.maps.MapView;
     
    public class MainActivity extends MapActivity implements LocationListener{
     
    	private MapView mapView;
    	private MapController mc;
     
    	private LocationManager lm;
     
    	private double latitude;
    	private double longitude;
    	private double altitude;
    	private float accuracy;
     
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
     
    		mapView = (MapView) this.findViewById(R.id.mapView);
    		mapView.setBuiltInZoomControls(true);
     
    		mc = mapView.getController();
    		mc.setZoom(17);
    	}
     
    	@Override
    	protected void onResume() {
    		super.onResume();
    		lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
    		if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER))
    			lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0,
    					this);
    		lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0,
    				this);
    	}
     
    	@Override
    	protected void onPause() {
    		super.onPause();
    		lm.removeUpdates(this);
    	}
     
    	@Override
    	protected boolean isRouteDisplayed() {
    		return false;
    	}
     
    	@Override
    	public void onLocationChanged(Location location) {
    		latitude = location.getLatitude();
    		longitude = location.getLongitude();
    		altitude = location.getAltitude();
    		accuracy = location.getAccuracy();
     
    		String msg = String.format(
    				getResources().getString(R.string.new_location), latitude,
    				longitude, altitude, accuracy);
    		Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
     
    		GeoPoint p = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
    		mc.animateTo(p);
    		mc.setCenter(p);
    	}
     
    	@Override
    	public void onProviderDisabled(String provider) {
    		String msg = String.format(
    				getResources().getString(R.string.provider_disabled), provider);
    		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    	}
     
    	@Override
    	public void onProviderEnabled(String provider) {
    		String msg = String.format(
    				getResources().getString(R.string.provider_enabled), provider);
    		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    	}
     
    	@Override
    	public void onStatusChanged(String provider, int status, Bundle extras) {
    		String newStatus = "";
    		switch (status) {
    		case LocationProvider.OUT_OF_SERVICE:
    			newStatus = "OUT_OF_SERVICE";
    			break;
    		case LocationProvider.TEMPORARILY_UNAVAILABLE:
    			newStatus = "TEMPORARILY_UNAVAILABLE";
    			break;
    		case LocationProvider.AVAILABLE:
    			newStatus = "AVAILABLE";
    			break;
    		}
    		String msg = String.format(
    				getResources().getString(R.string.provider_disabled), provider,
    				newStatus);
    		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    	}
    }
    activity_main.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
     
            <com.google.android.maps.MapView
            android:id="@+id/mapView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:apiKey="AIzaSyA5yiULAFnY2CHN8RlW5Amk1SgKeoel7Uo"
            android:clickable="true"
         />
     
    </RelativeLayout>
    LocalisationManifest.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.localisation"
        android:versionCode="1"
        android:versionName="1.0" >
     
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="19" />
     
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     
        <application
            android:allowBackup="true"
            android:icon="@drawable/maps"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <uses-library android:name="com.google.android.maps" />
     
            <activity
                android:name="com.example.localisation.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
     
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
     
            <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="AIzaSyA5yiULAFnY2CHN8RlW5Amk1SgKeoel7Uo" />
        </application>
     
    </manifest>
    strings.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
     
        <string name="app_name">Localisation</string>
        <string name="action_settings">Settings</string>
        <string name="hello_world">Hello world!</string>
        <string name="provider_enabled">The provider %s is now enabled</string>
        <string name="provider_disabled">The provider %s is now disabled</string>
        <string name="provider_new_status">The provider %1$s has now a new status %2$s</string>
        <string name="new_location">New Location : Latitude = %1$s, Longitude = %2$s, Altitude = %3$s avec une précision de %4$s mètres </string>
     
    </resources>
    J'ai bien une ApiKey fourni par google. Je ne comprend pas d'ou viens mon erreur

    Je programme pour une appli sous Android 4.4.2.

    Un peu d'aide de votre part sera la bienvenue, car je ne vois pas comment faire.

    Je previens que je débute en programmation android.

    Merci d'avance

  2. #2
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Par défaut
    Ne serais-tu pas en cours avec dsjulien par hasard ? http://www.developpez.net/forums/d14...e-google-maps/

    Tu as exactement le même problème.
    Comment as-tu fait pour obtenir une clef pour ta GMaps ? Celles-ci ne sont plus dispo pour la GMap v1 que tu utilises.
    Pars-tu d'un tutoriel ? Ou d'une application déjà existante ?

    Ps : le RelativeLayout dans ton XML est inutile.
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2013
    Messages
    40
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2013
    Messages : 40
    Par défaut
    Merci de ta réponse Hizin !!

    Non je ne suis pas en cours avec dsjulien.

    Effectivement je me suis grandement inspiré d'un tutoriel.

    Pour la clé API je suis allé sur le site de google : https://code.google.com/apis/console...9746266:access

  4. #4
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Par défaut
    La console Google donne une clef GMap Api V2. Tu utilises la V1. Mets le tutoriel que tu as utilisé à la poubelle, il ne sert plus à rien, sauf à titre de curiosité.

    Je te suggère plutôt de partir de la documentation officielle : https://developers.google.com/maps/d.../android/start
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2013
    Messages
    40
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2013
    Messages : 40
    Par défaut
    Comme tu le suggère je repars avec la doc officielle.

    Comment avoir une clé GMap Api V2 ?

  6. #6
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Par défaut
    Comme dit, la console Google que tu as utilisé te permet d'avoir une clef V2 avec le couple certificat signé + package.
    Tu as donc déjà ta clef, et c'était le problème d'ailleurs, puisque tu utilisais une clef GMaps V2 sur une GMaps V1.
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

Discussions similaires

  1. problème affichage google Map android V2
    Par mayssa_salhi dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 22/02/2014, 10h45
  2. Problème d'affichage carte Google Maps
    Par dsjulien dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 01/02/2014, 21h13
  3. Problém affichage maps view android
    Par othman22222 dans le forum Composants graphiques
    Réponses: 1
    Dernier message: 03/06/2013, 10h23
  4. Problème affichage map V2
    Par janyoura dans le forum Android
    Réponses: 3
    Dernier message: 28/03/2013, 18h47
  5. [IE 8] Problème affichage Google Maps
    Par Sekigawa dans le forum IE
    Réponses: 3
    Dernier message: 08/09/2010, 14h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo