【问题标题】:Google Maps in the Eclipse Emulator doesn't appearEclipse 模拟器中的谷歌地图没有出现
【发布时间】:2013-11-21 14:47:56
【问题描述】:

我可以放大和缩小,我也可以放置一个图标标记,但问题是地图没有出现,我只能看到一个网格。应该是什么这里有问题?这是否涉及 Google Maps API?

【问题讨论】:

  • 它显示网格意味着你需要签署你的应用程序然后运行。
  • 如何签署我的应用程序?对不起,我还是个初学者..
  • 你在Androidmanifest.xml中粘贴api密钥吗....
  • @ManetiVinay 根据我的代码源,我在 activity_main.xml 上有它..

标签: android eclipse google-maps maps emulation


【解决方案1】:

我终于在我的模拟器中获得了地图。我按照这些步骤来实现它。

  1. 创建avd并启动模拟器

  2. 转到 Android SDK 中存在的平台工具路径并将这些 apk 放入其中。

    • com.android.vending-20130716
    • com.google.android.gms-20130716
  3. 通过使用命令提示符(shift+右键单击-->在此处打开命令窗口)转到平台工具路径,一一安装这些 apk。按照这些命令
    • adb 设备
    • adb install com.android.vending-20130716
    • adb install com.google.android.gms-20130716
  4. 导入位于项目位置的 google-play-services_lib 项目并将其添加到您的项目中。
  5. 重新启动模拟器并清理您的项目并通过模拟器运行它。

就是这样。 :) 您可以从以下链接下载上面的 apk

Running Google Maps v2 on the Android emulator

【讨论】:

【解决方案2】:

请看这里: Running Google Maps v2 on the Android emulator

模拟器不喜欢谷歌地图的 v2。如果地图保持灰色,请在真实设备上进行测试。 如果是这样,您的签名密钥很可能配置错误。确保您还在 Google API 控制台上注册了开发密钥。

【讨论】:

    【解决方案3】:

    尝试添加 goolge play services 的元标记..

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    

    【讨论】:

    • 这对模拟器没有帮助
    • 甚至你应该启用 google map api v2 服务于 google map api 控制台...
    • 您生成的 api 密钥是否包含在 Android 清单文件中的包名?
    • 你有没有在androidmainfest.xml
    • 那么你在 log-cat 中是否有任何错误,如果你发布了它。
    【解决方案4】:

    这是在我的 Android 清单中

    <?xml version="1.0" encoding="utf-8"?>
    
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.cmumap"
      android:versionCode="1"
      android:versionName="1.0">
    
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    
    <permission
        android:name="com.android.cmumap.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    
    <uses-permission android:name="com.android.cmumap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission   android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
    
        <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    
        <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
            android:value="my API key"/>
    
        </activity>
    
        <uses-library android:name="com.google.android.maps" />
    
        <meta-data
            android:name="com.google.android gms.version"
            android:value="@integer/google_play_services_version"/>
    
    </application>
    
    </manifest>
    

    对于主要活动,我有这些

    package com.android.cmumap;
    
    import java.util.List;
    
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapActivity;
    import com.google.android.maps.MapController;
    import com.google.android.maps.MapView;
    import com.google.android.maps.Overlay;
    import com.google.android.maps.OverlayItem;
    
    public class MainActivity extends MapActivity {
    
    private MapView mapView;
    
    private static final int latitudeE6 = 37985339;
    private static final int longitudeE6 = 23716735;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        mapView = (MapView) findViewById(R.id.map_view);       
        mapView.setBuiltInZoomControls(true);
    
        List mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
        CustomItemizedOverlay itemizedOverlay = 
             new CustomItemizedOverlay(drawable, this);
    
        GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
        OverlayItem overlayitem = 
             new OverlayItem(point, "Hello", "I'm in Athens, Greece!");
    
        itemizedOverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedOverlay);
    
        MapController mapController = mapView.getController();
    
        mapController.animateTo(point);
        mapController.setZoom(6);
    
    }
    
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
    
    }
    

    还有这个activity_main

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" 
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
    
     <com.google.android.maps.MapView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map_view"
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"
      android:clickable="true" 
      android:enabled="true" 
      android:apiKey="my API Key" />
    
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2018-05-19
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 2014-02-06
      • 1970-01-01
      • 2020-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多