0

我完全按照这里给出的步骤。API 密钥是通过以下步骤获得的这里 我已经上传了市场上的 apk 用于测试目的,但它仍然没有显示地图,尽管它显示带有调试密钥的地图。但是当我尝试使用发布谷歌地图密钥时,它显示带有放大和缩小的白屏按钮,但没有地图。

谷歌游戏商店链接

地图片段

public class CustomMap extends SupportMapFragment {

private static final int ZOOMIN_ANIMATION_DURATION = 300;

public static CustomMap newInstance() {
    Bundle bundle = new Bundle();
    CustomMap customMap = new CustomMap();
    customMap.setArguments(bundle);
    return customMap;

}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

}

@Override
public void onResume() {
    super.onResume();
    GoogleMap googleMap = getMap();
    if (googleMap == null) {
    } else {
        LatLng mLatLng = new LatLng(70.00,
                33.00);

        googleMap.addMarker(new MarkerOptions()
                .title("Title")
                .snippet("Address")
                .position(mLatLng)
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.ic_launcher)));
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(mLatLng));
        googleMap.animateCamera(CameraUpdateFactory.zoomBy(10),
                ZOOMIN_ANIMATION_DURATION, null);
    }
}

}

主要活动

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

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

}

XML

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<fragment
    android:id="@+id/fragment1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    class="com.example.maptest.CustomMap" 
  />

</RelativeLayout>

显现

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

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<permission
    android:name="com.baresso.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"   />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.maptest.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyDcAy3bEVhv_lhAH1hHNHk_RpvyXiN0xNI" />
</application>

</manifest>
4

4 回答 4

2

https://developers.google.com/maps/documentation/android/start

  1. 我认为问题在于获取 API 密钥或使用 SHA-1 指纹。
  2. 您是否在Google 控制台中提供带有 SHA-1 指纹的应用程序包
  3. 将 Google Play 服务安装到您的模拟器或 Android 设备中。
  4. 请首选 Android 设备进行地图测试。
于 2013-06-21T10:04:38.827 回答
1

谷歌地图将无法使用其政策的最新变化,这些变化直接限制了谷歌地图库的使用。

要解决此问题,您必须将整个谷歌地图作为第三方插件包含在内,或者您可以在 web 视图中显示谷歌地图并通过 javascript html 函数传递位置。

例如:--

<script>
function initialize()
{
document.getElementById('dummyDIV').innerHTML = '<div id="googleMap"     
style="width:'+screen.width+'px;height:'+screen.height+'px;"></div>';
var sURL1 = window.document.URL;
var sURL2 =sURL1.split("%20");
var sURL= sURL2[0];
for (j=1;j<sURL2.length;j++){
    sURL = sURL+' '+sURL2[j];
} 

var mapProp = {
  center:new google.maps.LatLng(19.155721,72.856025),
  zoom:10,
  disableDefaultUI:true, 
  zoomControl:true,
  mapTypeControl:true,
  mapTypeId:google.maps.MapTypeId.ROADMAP

  };

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);


   if (sURL.indexOf("?") > 0)
{
var bifurcatedURL = sURL.split("?");    

var everyMarker = bifurcatedURL[1].split("&");  
for (i=0;i<everyMarker.length;i++)
    {
        var markerDetails =everyMarker[i].split("+");
        var lat = (markerDetails[0]);
        var lon = (markerDetails[1]);
        var address =markerDetails[2];
        var type = markerDetails[3];
        var markerPosition = new google.maps.LatLng(lat,lon);
        map.setCenter(markerPosition);
        if(type=='a'||type=='A')
    var marker=new 
google.maps.Marker({position:markerPosition,icon:'atm_marker.png'});
        else if(type=='b'||type=='B')
 var marker=new google.maps.Marker
 ({position:markerPosition,icon:'branch_marker.png'});
        else if(type=='c'||type=='C')
var marker=new google.maps.Marker({position:markerPosition,icon:'pin_blue.png'});

            marker.setMap(map);
    var infowindow = new             google.maps.InfoWindow({content:address});
            listenMarker(marker,address,infowindow,map)
    }
}   
}

function listenMarker (marker,address,infowindow,map)
{
// so marker is associated with the closure created for the listenMarker function call
google.maps.event.addListener(marker, 'click', function() {
                    infowindow.open(map, marker);
                });
}

 google.maps.event.addDomListener(window, 'load', initialize);
</script>
于 2013-06-21T09:48:23.360 回答
0

问题就在这里

<permission
android:name="com.baresso.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

用你自己的包名替换它..

<permission
android:name="com.example.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

和这里

替换这个

<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
with <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" />  
于 2013-06-21T10:43:20.830 回答
0

当您签署 apk 时从 logcat 复制 SHA1 单击完成并将其添加到您的 google play 开发人员控制台项目 SHA-1 证书指纹这将显示您的带有 signeg apk 的地图

于 2016-04-14T04:47:40.547 回答