How to use Google Maps API v2 with API level 10?

前端 未结 4 1497
忘掉有多难
忘掉有多难 2020-12-11 22:16

According to 1 the code posted there can be used for Android API 12 or later. I tried the code on an emulator having API level 10 (Google API platform 2.3.3) and I get the f

相关标签:
4条回答
  • 2020-12-11 22:55

    i use below code hope use full to you:-

    packages and extend

    import android.support.v4.app.FragmentActivity;
    import com.google.android.gms.maps.CameraUpdateFactory;
    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.SupportMapFragment;
    import com.google.android.gms.maps.model.BitmapDescriptorFactory;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.MarkerOptions;
    
    public class UserLocation extends FragmentActivity 
    

    code

        android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
        SupportMapFragment mapFragment = (SupportMapFragment) fragmentManager
                .findFragmentById(R.id.map);
        googleMap = mapFragment.getMap();
    

    works for me.

    SupportMapFragment

    http://developer.android.com/reference/com/google/android/gms/maps/SupportMapFragment.html

    0 讨论(0)
  • 2020-12-11 23:05

    instead of using com.google.android.gms.maps.MapFragment use com.google.android.gms.maps.SupportMapFragment and for the Activity it will have to switched to be FragmentActivity as mentioned in the comment below

    0 讨论(0)
  • 2020-12-11 23:09

    For earlier APIs, you need to use SupportmapFragment. See the SupportMapFragment docs, Basically use class="com.google.android.gms.maps.SupportMapFragment" instead of class="com.google.android.gms.maps.MapFragment"

    0 讨论(0)
  • 2020-12-11 23:11

    { Use this as a Reference for codes.. http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/

    also in the above example one has to use his own Api Key in metadata tag of manifest instructions for generating Api key are given }

    now if you want to implement this code in android 2.3


    1)first change the Manifest

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />
    

    then Rightclick>Properties>Android>Android 2.3


    2)there are two google play service libraries

       a)..\sdk\extras\google\google_play_services_froyo\libproject\google-play-services_lib
    
       b)..\sdk\extras\google\google_play_services\libproject\google-play-services_lib
    

    if you'r working on android 2.3 try having the first one a as a library project (you will first need to import it as a library project File>import>................)


    3)then follow instructions here


    4)see to it that your Google play services app is up to date on your device

    0 讨论(0)
提交回复
热议问题