谷歌地图显示genymotion空白 [英] google map showing blank in genymotion

查看:446
本文介绍了谷歌地图显示genymotion空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌Nexus 4.2.2 - 与谷歌Genymotion API。谷歌地图片段快到了空。我曾与API注册,并提供清单文件的关键。感谢您的帮助。

I am using Google Nexus 4.2.2 - with Google API on Genymotion. The google maps fragment is coming up empty. I have registered with the API and providing the key in the manifest file. Thanks for your help.

布局:

<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=".MapsTestActivity" >

    <fragment
       android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"/>

</RelativeLayout>

活动:

package com.chaseit.activities;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.chaseit.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsTestActivity extends Activity {

    static final LatLng HAMBURG = new LatLng(53.558, 9.927);
    static final LatLng KIEL = new LatLng(53.551, 9.993);
    private GoogleMap map;

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

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        setupMap();
        super.onResume();
    }

    private void setupMap() {

        GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.map)).getMap();

        Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
                .title("Hamburg"));
        Marker kiel = map.addMarker(new MarkerOptions()
                .position(KIEL)
                .title("Kiel")
                .snippet("Kiel is cool")
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.ic_launcher)));

        // Move the camera instantly to hamburg with a zoom of 15.
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

        // Zoom in, animating the camera.
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.maps_test, menu);
        return true;
    }

}

我从 http://www.vogella.com的例子code /articles/AndroidGoogleMaps/article.html

推荐答案

中序使用谷歌地图V2在我们的Andr​​oid应用程序,你必须使用谷歌播放服务库。如果上下文传递给检查服务是否可用该设备本库才有效。加入这一行你的OnCreate

Inorder to use google maps v2 in our android application, one must use google-play-services library. This Library works only if context is passed to check whether services is available to that devices. Add this line in your oncreate

GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

评论我对结果

这篇关于谷歌地图显示genymotion空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆