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

Composants graphiques Android Discussion :

Probl�m affichage maps view android


Sujet :

Composants graphiques Android

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    D�cembre 2008
    Messages
    110
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : D�cembre 2008
    Messages : 110
    Par d�faut Probl�m affichage maps view android
    Bonjour ,

    je travaille sur un petit projet sous android j'ai essaye l'affichage d'une map view mais la maps veut pas s'afficher je sais pas d'ou vient le bl�m
    la cl� je l'ai bien g�n�r�e


    voila le code source

    mon activit�

    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
    package com.example.testdeath;
     
    import java.util.List;
     
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
     
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapActivity;
    import com.google.android.maps.MapController;
    import com.google.android.maps.MapView;
    import com.google.android.maps.Overlay;
    import com.google.android.maps.OverlayItem;
     
    public class MainActivity extends MapActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
            // Displaying Zooming controls
            MapView mapView = (MapView) findViewById(R.id.mapView);
            mapView.setBuiltInZoomControls(true);
     
            /**
             * Changing Map Type
             * */
            // mapView.setSatellite(true); // Satellite View
            // mapView.setStreetView(true); // Street View
            // mapView.setTraffic(true); // Traffic view
     
            /**
             * showing location by Latitude and Longitude
             * */        
            MapController mc = mapView.getController();
            double lat = Double.parseDouble("48.85827758964043");
            double lon = Double.parseDouble("2.294543981552124");
            GeoPoint geoPoint = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6));
            mc.animateTo(geoPoint);
            mc.setZoom(15);
            mapView.invalidate(); 
     
     
            /**
             * Placing Marker
             * */
            List<Overlay> mapOverlays = mapView.getOverlays();
            Drawable drawable = this.getResources().getDrawable(R.drawable.mark_red);
            AddItemizedOverlay itemizedOverlay = 
                 new AddItemizedOverlay(drawable, this);
     
     
            OverlayItem overlayitem = new OverlayItem(geoPoint, "Hello", "Sample Overlay item");
     
            itemizedOverlay.addOverlay(overlayitem);
            mapOverlays.add(itemizedOverlay);
     
        }
     
    	@Override
    	protected boolean isRouteDisplayed() {
    		return false;
    	}
    }

    lautre activit�




    l'interface mapview

    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
    <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
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="AIzaSyB9ONJU7ffPOlURR-QwVLL2tpqIQ12wPTs"
    />
     
    </RelativeLayout>


    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
    package com.example.testdeath;
     
    import java.util.ArrayList;
     
    import android.content.Context;
    import android.graphics.drawable.Drawable;
    import android.util.Log;
    import android.view.MotionEvent;
    import android.widget.Toast;
     
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.ItemizedOverlay;
    import com.google.android.maps.MapView;
    import com.google.android.maps.OverlayItem;
     
    public class AddItemizedOverlay extends ItemizedOverlay<OverlayItem> {
     
    	   private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
     
    	   private Context context;
     
    	   public AddItemizedOverlay(Drawable defaultMarker) {
    	        super(boundCenterBottom(defaultMarker));
    	   }
     
    	   public AddItemizedOverlay(Drawable defaultMarker, Context context) {
    	        this(defaultMarker);
    	        this.context = context;
    	   }
     
    	   @Override
    	   protected OverlayItem createItem(int i) {
    	      return mapOverlays.get(i);
    	   }
     
    	   @Override
    	   public int size() {
    	      return mapOverlays.size();
    	   }
     
    	   @Override
    	   protected boolean onTap(int index) {
    		  Log.e("Tap", "Tap Performed");
    	      return true;
    	   }
     
    	   public void addOverlay(OverlayItem overlay) {
    	      mapOverlays.add(overlay);
    	       this.populate();
    	   }
     
    	   /**
                * Getting Latitude and Longitude on Touch event
                * **/
    	   @Override
           public boolean onTouchEvent(MotionEvent event, MapView mapView) 
           {   
     
               if (event.getAction() == 1) {                
                   GeoPoint geopoint = mapView.getProjection().fromPixels(
                       (int) event.getX(),
                       (int) event.getY());
                   // latitude
                   double lat = geopoint.getLatitudeE6() / 1E6;
                   // longitude
                   double lon = geopoint.getLongitudeE6() / 1E6;
                   Toast.makeText(context, "Lat: " + lat + ", Lon: "+lon, Toast.LENGTH_SHORT).show();
               }                            
               return false;
           } 
     
    	}

    String.xml

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
     
        <string name="app_name">testdeath</string>
        <string name="action_settings">Settings</string>
        <string name="hello_world">Hello world!</string>
     
    </resources>

    android manifest

    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.testdeath"
        android:versionCode="1"
        android:versionName="1.0" >
     
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />
     
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
     
     
            <!--  Add Google Map Library -->
            <uses-library android:name="com.google.android.maps" />
     
            <activity
                android:name="com.example.testdeath.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>
        </application>
     
           <!-- Allow to connect with internet -->
    	<uses-permission android:name="android.permission.INTERNET" />
    </manifest>
    Images attach�es Images attach�es  

  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
    Merci d'utiliser les balises code (bouton #) pour aider � la lisibilit�.

    Tu utilises une MapActivity, qui est d�pr�ci�e, et les clefs permettant de voir la carte ne sont plus g�n�rables.

    Il faut que tu utilises la Google Map API V2 pour Android, c'est � dire la MapFragment (ou mieux : la SupportMapFragment) n�cessitant la pr�sence de Google Play Services sur le t�l�phone cible, ainsi que la pr�sence de OpenGL.
    C'est Android, PAS Androd, ou Androde 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 affichage Map google
    Par cartman_94 dans le forum API standards et tierces
    R�ponses: 19
    Dernier message: 07/02/2014, 14h39
  3. Probl�me affichage map V2
    Par janyoura dans le forum Android
    R�ponses: 3
    Dernier message: 28/03/2013, 18h47
  4. Probl�me affichage de Views (TextView, ImageView)
    Par Ryu2000 dans le forum Composants graphiques
    R�ponses: 9
    Dernier message: 19/04/2011, 11h10
  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