All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE - Welcome to ANDROID KAWE, Ini adalah sebuah blog directory tentang burung,baik itu suara burung ataupun tips perawatan burung.Blog ini adalah situs perangkum otomatis dari pencarian google yang kali ini berjudul All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE.Ada ribuan artikel yang sudah terekam ke dalam situs ini,silahkan cari sesuai yang kalian kehendaki,untuk artikel selanjutnya tentang judul diatas bisa kalian baca di bawah ini.
Konten : All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
Judul : All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
Location aware applications on android platform needs an intuitive way to present the location information.
Google provides a set of APIs to integrate the Google Map for development of android applications and bundled as Google APIs.
This post is focusing on Google Map object integration with android application.
Create a Android application project "GMapSample" and open the default class file generated in the src directory as the main activity class. See here the project creation dialog
To create the Google Map in the application you need to select the Build SDK as Google APIs (API15). If this is not available then you need to update the SDK and download using Android SDK Manager.
The following includes need to add in order to integrate the Google Map with your application.
The MapActivity extends the basic Activity class of Android and provides the Google Map as the user interface.
In order to access the Google Map in your application you need to get a Application Key and define the Google Map object in your application XML layout.
To get the API key for your application see the following link.
http://creativeandroidapps.blogspot.in/2012/07/get-application-key-for-google-map.html
Now replace the code of main activity class by following code
while compiling the application you will get some error because we have not added the use of google APIs in AndroidManifest.xml file of the application.
Add the following line in your application manifest file.
<uses-library android:name="com.google.android.maps" />
Add the following permissions also to manifest file.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
To run the application you need to define a AVD from the AVD Manager as follows
Running the application will give the following output.
Please provide your feedback. The next post for the Google Map is on the way.
Thanks
Creative Android Apps
Anda sedang membaca artikel All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE dan artikel ini url permalinknya adalah https://androidkawe.blogspot.com/2016/10/all-about-android-google-map-in-android.html Semoga artikel ini bisa bermanfaat.Sekali lagi,ini adalah situs auto yang tidak ditulis langsung oleh admin,Kami tidak menjamin akan kebenaran dari artikel yang tertulis.
Konten : All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
Judul : All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
Sample Code - Google Map in Android Application
Location aware applications on android platform needs an intuitive way to present the location information.
Google provides a set of APIs to integrate the Google Map for development of android applications and bundled as Google APIs.
This post is focusing on Google Map object integration with android application.
Create a Android application project "GMapSample" and open the default class file generated in the src directory as the main activity class. See here the project creation dialog
Create New Android Application Project Using Eclipse |
The following includes need to add in order to integrate the Google Map with your application.
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
The MapActivity extends the basic Activity class of Android and provides the Google Map as the user interface.
In order to access the Google Map in your application you need to get a Application Key and define the Google Map object in your application XML layout.
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0HvaRYYCBNDap4SKY0HN-XXXXXXXXXXXXXXXX"
/>
To get the API key for your application see the following link.
http://creativeandroidapps.blogspot.in/2012/07/get-application-key-for-google-map.html
Now replace the code of main activity class by following code
package com.example.gmapsample;
import android.os.Bundle;
import android.view.Menu;
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 GMapSample extends MapActivity{
private static final String TAG = "GMapSample";
private MapView mapView;
private MapController mapController;
private static final int latitudeE6 = 17421306;
private static final int longitudeE6 = 78457553;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gsample);
mapView = (MapView) findViewById(R.id.map_view); //get the map view resource added in XML file
mapView.setBuiltInZoomControls(true);
GeoPoint point = new GeoPoint(latitudeE6, longitudeE6); //defines the geo location
mapController = mapView.getController(); //get the map controller
mapController.animateTo(point); // show the location defined by geopoint
mapController.setZoom(7); //setting the map zoom level
mapView.invalidate(); //redraw the map
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_gsample, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
while compiling the application you will get some error because we have not added the use of google APIs in AndroidManifest.xml file of the application.
Add the following line in your application manifest file.
<uses-library android:name="com.google.android.maps" />
Add the following permissions also to manifest file.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
To run the application you need to define a AVD from the AVD Manager as follows
AVD for Google Map |
Running the application will give the following output.
Android Application with Google Map |
Thanks
Creative Android Apps
Demikianlah Artikel All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE
Semoga artikel tentang All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE, mudah-mudahan bisa memberi manfaat untuk anda semua.
Anda sedang membaca artikel All About Android-Google Map in Android Application - Sample Code-ANDROIDKAWE dan artikel ini url permalinknya adalah https://androidkawe.blogspot.com/2016/10/all-about-android-google-map-in-android.html Semoga artikel ini bisa bermanfaat.Sekali lagi,ini adalah situs auto yang tidak ditulis langsung oleh admin,Kami tidak menjamin akan kebenaran dari artikel yang tertulis.
Tag :
Andoird,
Google Map