To implement Google Maps Android API v2 , follow the steps:
- Setup Google Play services SDK in Eclipse.
- Displaying the SHA1 certificate fingerprint, for debug and release.
- Generate Debug API Key for Google Maps Android API v2 service, for testing and coding.
- Add reference library google-play-services.jar to project using MapFragment and SupportMapFragment.
- If you have NoClassDefFoundError when using Support Library, check Tips to add Support Library.
- (updated@2013-07-26: now support...) Don't test App using Google Maps Android API v2 on Android emulator, it's not supported.
- Modify AndroidManifest.xml for Google Maps Android API v2.
- Coding, described in this post.
- Create and Obtain API Key for Google Maps Android API v2 service, replace Debug API Key with Release API Key for API.
- May be you have to Turn off Lint Error Checking when Export Signed Application Package.
- Using SupportMapFragment for device run API Level below 12.
- Google Maps Android API v2 with blank map displayed, wrong API Key assigned.
- Include open source software license information/Legal Notices in your app using Google Maps Android API v2.
- Check if correct Google Play Service available for Google Maps Android API v2.
- Get GoogleMap from MapFragment/SupportMapFragment
- Display my location on Google Maps Android API v2
- Set map type of GoogleMap
- Detect user touch on GoogleMap and animate to the touched location
- Using MapFragment instead of SupportMapFragment
- Detect long click on map and add marker
- Detect MarkerClick and add Polyline
- Draw Polygon on GoogleMap
- Implement Draggable Marker
- Display ZoomControls, Compass and MyLocation buttons on GoogleMap
- Enable/Disable various gestures for GoogleMap
- Turn on Traffic Layer
- Change color of default marker
- Implement bouncing marker
- Create custom info contents
- Implement Custom InfoWindowAdapter with dynamic icon
- Detect Info Window Click, implements OnInfoWindowClickListener
- Display another layout over GoogleMap
- Implement LocationSource and LocationListener
- Detect and animate to user location
- Create MapFragment and GoogleMap using Java code
- Set options in XML
- Move Google Maps V2 with auto best zoom
- Animation on Google Maps Android API v2
- GoogleMap animation with zoom
- Google Maps V2 Animation with bearing
- Convert between LatLng and Location
- Draw Circle on GoogleMap, with Google Play services v3.0
- Draw tranparent circle
- Implement OnMyLocationChangeListener
- Draw hollow Polygon on Map, using addHole()
- Video of Kick-start Google Maps Android API v2 Development, by GoogleDevelopers
- Implement dual MapFragment
- Retain instance of MapFragment
- Draw Polyline from touched location to MyLocation
- Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto"
- To test apps using Google Play Service on emulator, install AVD with Google APIs platform based on Android 4.2.2 or higher
- Introduction Video - New Features in the Google Maps Mobile APIs for Android and iOS
- Very nice intro at updated Google Maps Android API v2 documentation page
Now, it's time to implement your code to add Google Maps Android API v2. Notice that you have to keep both your project and google-play-services_lib opened in Eclipse.
Please note that the code below is only useful for testing your settings in an application targeting Android API 12 or later, This code should not be used in a production application.
Modify layout to add frqgment of com.google.android.gms.maps.MapFragment.
<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"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
</RelativeLayout>
Main code, actually nothing changed.
package com.example.androidmapsv2;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Download the files.
Exported AndroidMapsV2.apk
Related:
- When Android Meets Maps, Google I/O 2013 video
0 comments:
Post a Comment