图形页面中灰瓦显示地图不是在谷歌Android 2.3.3 API显示 [英] MapView showing in grey tiles map not showing in android google api 2.3.3

查看:204
本文介绍了图形页面中灰瓦显示地图不是在谷歌Android 2.3.3 API显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我开发一个地图视图我试着按以下方式
 我通过点击一个按钮]创建的意图。新增的权限和库
。我创建了一个覆盖项目。
。我模拟器的目标是为GoogleApi 2.3.3。我的MapView键obdained和asigned到mapview.xml

Hello I am developing a map view I tried to following way I created an "Intent" by clicking on a button]. Added permission and library . I created an overlay item. .My Emulator is targeted as GoogleApi 2.3.3 .My MapView key is obdained and asigned into mapview.xml

我看到的地图与底部和地图视图CONTROLER一个谷歌的标志:这里是我的code

I am seeing the map with a google logo at bottom and map view controler: here is my code

MapView.xml

MapView.xml

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <view android:id="@+id/mv"
    class="com.google.android.maps.MapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" 
    android:clickable="true"
    android:apiKey="046S_m5BQ43JIRtKiXQfldWwo2ddlU6dL6ca9SQ"
    />
    </LinearLayout>

MapViewActivity.java

MapViewActivity.java

    public class MapviewActivity extends MapActivity
   { private static double lat = 35.952967;   // Temporary test values for lat/long
    private static double lon = -83.929158 ;
    private int latE6;
   private int lonE6;
  private MapController mapControl;
private GeoPoint gp;
private MapView mapView; 
private LocationManager locationManager;
private MyOverlays itemizedoverlay;
private MyLocationOverlay myLocationOverlay;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.mapview);

        mapView = (MapView) findViewById(R.id.mv);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(true);
        mapControl = mapView.getController();
        mapControl.setZoom(12); // Zoon 1 is world view
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
                0, new GeoUpdateHandler());

        myLocationOverlay = new MyLocationOverlay(this, mapView);
        mapView.getOverlays().add(myLocationOverlay);

        myLocationOverlay.runOnFirstFix(new Runnable() {
            public void run() {
                mapView.getController().animateTo(
                        myLocationOverlay.getMyLocation());
            }
        });

        Drawable drawable = this.getResources().getDrawable(R.drawable.point);
        itemizedoverlay = new MyOverlays(this, drawable);
        createMarker();
    }



    public class GeoUpdateHandler implements LocationListener {

        @Override
        public void onLocationChanged(Location location) {
            int lat = (int) (location.getLatitude() * 1E6);
            int lng = (int) (location.getLongitude() * 1E6);
            GeoPoint point = new GeoPoint(lat, lng);
            createMarker();
            mapControl.animateTo(point); // mapController.setCenter(point);

        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    }

    private void createMarker() {
        GeoPoint p = mapView.getMapCenter();
        OverlayItem overlayitem = new OverlayItem(p, "", "");
        itemizedoverlay.addOverlay(overlayitem);
        if (itemizedoverlay.size() > 0) {
            mapView.getOverlays().add(itemizedoverlay);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        myLocationOverlay.enableMyLocation();
        myLocationOverlay.enableCompass();
    }

    @Override
    protected void onPause() {
        super.onResume();
        myLocationOverlay.disableMyLocation();
        myLocationOverlay.disableCompass();
    }




    // to set the satellite and traffic view
    public boolean onKeyDown(int keyCode, KeyEvent e){
    if(keyCode == KeyEvent.KEYCODE_S){
        mapView.setSatellite(mapView.isSatellite());
        return true;
    } else if(keyCode == KeyEvent.KEYCODE_T){
        mapView.setTraffic(mapView.isTraffic());
        mapControl.animateTo(gp);  // To ensure change displays immediately
    }
    return(super.onKeyDown(keyCode, e));
}     
// Required method since class extends MapActivity
protected boolean isRouteDisplayed() {
    return true;  // display a route
}

这是我的MyOverlays.java

here is my MyOverlays.java

 public class MyOverlays extends ItemizedOverlay<OverlayItem> {

        private static int maxNum = 5;
        private OverlayItem overlays[] = new OverlayItem[maxNum];
        private int index = 0;
        private boolean full = false;
        private Context context;
        private OverlayItem previousoverlay;

        public MyOverlays(Context context, Drawable defaultMarker) {
            super(boundCenterBottom(defaultMarker));
            this.context = context;
        }

        @Override
        protected OverlayItem createItem(int i) {
            return overlays[i];
        }

        @Override
        public int size() {
            if (full) {
                return overlays.length;
            } else {
                return index;
            }

        }

        public void addOverlay(OverlayItem overlay) {
            if (previousoverlay != null) {
                if (index < maxNum) {
                    overlays[index] = previousoverlay;
                } else {
                    index = 0;
                    full = true;
                    overlays[index] = previousoverlay;
                }
                index++;
                populate();
            }
            this.previousoverlay = overlay;
        }

        protected boolean onTap(int index) {
            OverlayItem overlayItem = overlays[index];
            Builder builder = new AlertDialog.Builder(context);
            builder.setMessage("This will end the activity");
            builder.setCancelable(true);
            builder.setPositiveButton("I agree", new OkOnClickListener());
            builder.setNegativeButton("No, no", new CancelOnClickListener());
            AlertDialog dialog = builder.create();
            dialog.show();
            return true;
        };

        private final class CancelOnClickListener implements
                DialogInterface.OnClickListener {
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(context, "You clicked yes", Toast.LENGTH_LONG)
                        .show();
            }
        }

        private final class OkOnClickListener implements
                DialogInterface.OnClickListener {
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(context, "You clicked no", Toast.LENGTH_LONG).show();
            }
        }
    }

我Android.manifest

My Android.manifest

<uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>

     <application
        android:icon="@drawable/drive_eat_icon"
        android:label="@string/app_name" android:allowClearUserData="true"        android:debuggable="true">
        <activity
            android:name=".MainScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".DriveatmapActivity"></activity>
        <activity android:name=".MapviewActivity"></activity>
        <activity android:name=".FoodjointListActivity"></activity>
        <activity android:name=".SubmitFormActivity"></activity>    
        <activity android:name=".MyOverlays"/>
            <uses-library android:required="true" android:name="com.google.android.maps"></uses-library>
</application>

请建议做什么。如果您需要任何code,请让我知道。
我看到了谷歌地图只用灰瓦。

please suggest what to do . if you need any code please let me know. I am seeing the google map with only grey tiles.

推荐答案

使用它来获取有效的API密钥 -

Use it to get the Valid API key--

这是确切的路径 -

that is the exact path--

keytool -list -keystore "C:\Users\XYZ\.android\debug.keystore"

对于总路径的命令提示符得到MD5 fingureprint的GoogleMap的API密钥----

Total path for cmd prompt to get the MD5 fingureprint for the GoogleMap API Key----

如果您使用的是日食,然后 -

if you are using eclipse then--

D:\eclipse\jre\bin>keytool -list -keystore "C:\Users\XYZ\.android\debug.keystore"

MD5 fingurePrint看起来像这样 -

MD5 fingurePrint will look like this--

 3E:F4:D6:E6:93:4D:BB:B8:62:3A:D6:0F:E0:FC:4C:65

当u得到的fingurePrint数afterthat获得API密钥使用此链接---

When u get the fingurePrint number afterthat to get the API Key use this link---

的http:// code.google.com /安卓/插件/谷歌的API /图-API signup.html

然后你也会得到你的系统的API密钥并能得到地图轻松instread电网....

Then u will get API key of your system and can get the Map easily instread of grids....

在您的MapView.xml使用此键---

Use this key in your MapView.xml---

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

  <com.google.android.maps.MapView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:clickable="true"
      android:enabled="true"
      android:apiKey="046S_m5BQ43JIRtKiXQfldWwo2ddlU6dL6ca9SQ" />

</LinearLayout>

这篇关于图形页面中灰瓦显示地图不是在谷歌Android 2.3.3 API显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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