Wednesday, February 17, 2010

Map Implementation

1. Open Command Prompt and generate using eh keytool


You can the debug.keystore path

> Open Eclipse-> Windows>Preferences>Android>Build



Run the Following command with keystore

> keytool -list -keystore <debug.keystore path>



  1. Register the Certificate fingerprint and get the map view along with api key


Go To http://code.google.com/android/maps-api-signup.html and place your certification key



Register your certification along with your google account.

You can get the Following Data

Thank you for signing up for an Android Maps API key!

Your key is:

<< COPY THE API KEY>>

This key is good for all apps signed with your certificate whose fingerprint is:


CERTIFICATION FINGER PRINTS

Here is an example xml layout to get you started on your way to mapping glory:


<com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="||API KEY||"/>




3. Create a map based android project.


1. Eclipse > New Project > Android Project > Select Google Map 1.5




4. Place MapView in the layout


  1. Create a class extends the MapActivity class

public class MainActivity extends MapActivity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}


@Override

protected boolean isRouteDisplayed() {

// TODO Auto-generated method stub

return false;

}

}



  1. Create a GeoPoint, MapView and MapController instance.


double latitude = 10.47, longitude = 79.10;

GeoPoint geoPoint = new GeoPoint((int) (latitude * 1000000),

(int) (longitude * 1000000));


MapView myMapView = (MapView) findViewById(R.id.myGMap);

myMapView.setSatellite(false);

myMapView.setBuiltInZoomControls(true);

myMapView.displayZoomControls(true);


MapController myMC = = myMapView.getController();

myMC.setCenter(geoPoint);

myMC.setZoom(15);



Need to Add the User Permission


<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>


<uses-permission android:name="android.permission.INTERNET"></uses-permission>



Need to Add the lib


<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="com.google.android.maps" />

.......

</application>


Hope this is helpful for you



2 comments:

  1. Hai Frnd, I want to implement maps in android without using google map. can u help me regarding on this.
    Thanks In Advance

    ReplyDelete
  2. hey.....can u temme hwo to use all this code in already a created project?......where i dont have to create a new proj.....

    ReplyDelete