Android Google Map Problem

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Android Google Map Problem

Postby Dipi » Fri Mar 15, 2013 7:54 am

I am getting problem in Google Map generate in my android application application can not run in emulator (bluestack) application can not run in my android phone too i have done following steps

1. Create Android application with "Google Map API" build support
2. Import "Google Play Service.jar" and "Android-SUpport.jar" files into lib folder
3. AndroidManifest file is as follows


Code: Select all
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.lightcone.mapoverlaydemo"
      android:versionCode="1"
      android:versionName="1.0">     
    <permission
            android:name="my.package.name.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission   android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name"    android:debuggable="true">
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_API_KEY_HERE" />   
    <activity android:name=".MapOverlayDemo"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".ShowTheMap" android:label="Lat/Long Location"> </activity>
        <uses-library android:name="com.google.android.maps" />
    </application>   
</manifest>


For getting api key I am doing following steps
1. install keytool in eclipse
2. create key for application
3. copy MD5 fingerprint from keytool
4. get api key of this MD5 fingerprint
5. put this api key into anroid.manifest file

4. Main.xml layout file is as follows


Code: Select all
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">   
        <view android:id="@+id/mv"
            class="com.google.android.maps.MapView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:clickable="true"
            android:apiKey="0AC60fg0vDtvqrgBsR9h-5GwZUIEY1QV23MWtoQ"/>               
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="0px"           
            >                                                   
        <Button android:id="@+id/doOverlay"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30px"
            android:layout_weight="1.0"
            android:textSize="12sp"   
            android:text="@string/overlay_label" />           
        <Button android:id="@+id/doAccess"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:textSize="12sp"
            android:text="@string/access_label" />
           
        <Button android:id="@+id/doRoute"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="30px"
            android:layout_weight="1.0"
            android:textSize="12sp"
            android:text="@string/route_label" />                       
        </LinearLayout>                   
    </FrameLayout>


5. main.java file is as follows

Code: Select all
    import com.lightcone.mapoverlaydemo.R;
    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 android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.Menu;
    import android.view.Window;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    public class ShowGGMapMainActivity extends MapActivity {

     private static double lat;
     private static double lon;
     private int latE6;
     private int lonE6;
     private MapController mapControl;
     private GeoPoint gp;
     private MapView mapView;
     private Button overlayButton, accessButton;
     
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_show_ggmap_main);
      
        // Add map controller with zoom controls
        mapView = (MapView) findViewById(R.id.mv);
        mapView.setSatellite(false);
        mapView.setTraffic(false);
        mapView.setBuiltInZoomControls(true);   // Set android:clickable=true in main.xml

        int maxZoom = mapView.getMaxZoomLevel();
        int initZoom = maxZoom-2;

        mapControl = mapView.getController();
        mapControl.setZoom(initZoom);
        // Convert lat/long in degrees into integers in microdegrees
        latE6 =  (int) (lat*1e6);
        lonE6 = (int) (lon*1e6);
        gp = new GeoPoint(latE6, lonE6);
        mapControl.animateTo(gp);   

        // Button to control food overlay
        overlayButton = (Button)findViewById(R.id.doOverlay);
        overlayButton.setOnClickListener(new OnClickListener(){     
            public void onClick(View v) {   

            }
        });
       
        // Button to control access overlay
        accessButton = (Button)findViewById(R.id.doAccess);
        accessButton.setOnClickListener(new OnClickListener(){     
            public void onClick(View v) {   
 
            }
        });
       
   }

   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_show_ggmap_main, menu);
      return true;
   }

   @Override
   protected boolean isRouteDisplayed() {
      // TODO Auto-generated method stub
      return false;
   }
   
    // Method to insert latitude and longitude in degrees
      public static void putLatLong(double latitude, double longitude){
           lat = latitude;
        lon =longitude;
      }
   
      // This sets the s key on the phone to toggle between satellite and map view
      // and the t key to toggle between traffic and no traffic view (traffic view
      // relevant only in urban areas where it is reported).
   
      public boolean onKeyDown(int keyCode, KeyEvent e){
        if(keyCode == KeyEvent.KEYCODE_S){
            mapView.setSatellite(!mapView.isSatellite());
            return true;
        } else if(keyCode == KeyEvent.KEYCODE_T){
            mapView.setTraffic(!mapView.isTraffic());
            mapControl.animateTo(gp);  // To ensure change displays immediately
        }
            return(super.onKeyDown(keyCode, e));
      }
      }



-> i am getting following error in android phone
"Application Map Overlay Demo(process com.lightcone.mapoverlaydemo) has stopped unexpectedly.Please Try again"


-> i am getting following error in blue stack emulator
"Application Failure Detection. Please Try Again"


can anybody help me what should i do now ? how should i resolve this problem so that i can generate google map into my android phone and emulator please let me know if any of solution is there rather than this please let me know if i am missing some additional settings

Thank YOu
Dipi
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Mar 14, 2013 7:05 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests