谷歌地图不显示任何地图

编程入门 行业动态 更新时间:2024-10-26 00:23:33
本文介绍了谷歌地图不显示任何地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不知道我的问题是什么,谷歌地图没有显示

I don't know what my problem is, the Google map is not showing

我更改项目属性为谷歌API和2.3.3没有错误显示

I have change the project property to Google API 2.3.3 and no errors are displaying

这是我的code:

Mapping.java

package com.mapping; import java.io.IOException; import java.util.List; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; import android.location.Address; import android.location.Geocoder; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; public class Mapping extends MapActivity { private MapView mapView = null; private Geocoder geoCoder = null; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); // latitude and longitude of Dallas, TX // set as starting point int lat = (int)(37.422006 * 1000000); //the geocoder requires integers... int lon = (int)(-122.084095 * 1000000); //make these into a GeoPoint: GeoPoint startPoint = new GeoPoint(lat, lon); mapView.getController().setZoom(12); mapView.getController().setCenter(startPoint); geoCoder = new Geocoder(this); } public void mapHandler(View v) { switch(v.getId()) { case R.id.btnSat: mapView.setSatellite(true); break; case R.id.btnTraf: mapView.setTraffic(true); break; case R.id.btnNorm: mapView.setSatellite(false); mapView.setTraffic(false); break; } } public void geocode(View v) { EditText geoLocation = (EditText) findViewById(R.id.txtLocation); if(Geocoder.isPresent()) { try { String addr = geoLocation.getText().toString(); List<Address> locationList = geoCoder.getFromLocationName(addr, 5); if(locationList != null && locationList.size() > 0) { int lat = (int)(locationList.get(0).getLatitude() * 1000000); int lon = (int)(locationList.get(0).getLongitude() * 1000000); GeoPoint setPoint = new GeoPoint(lat, lon); mapView.getController().setZoom(14); mapView.getController().setCenter(setPoint); } } catch (IOException error) { Log.i("Caught IOException", "-----Printing Stack Trace-----"); error.printStackTrace(); } } else { geoLocation.setText("No Geocoder Available"); } } protected boolean isLocationDisplayed() { return false; } protected boolean isRouteDisplayed() { return false; } }

的main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/btnSat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Satellite" android:onClick="mapHandler" /> <Button android:id="@+id/btnTraf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Traffic" android:onClick="mapHandler" /> <Button android:id="@+id/btnNorm" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Normal" android:onClick="mapHandler" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <EditText android:id="@+id/txtLocation" android:layout_width="200sp" android:layout_height="wrap_content" android:text="Dallas" /> <Button android:id="@+id/btnGeocode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Find Location" android:onClick="geocode" /> </LinearLayout> <com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:apiKey="0G_pKeFNWX5lw7PQ7AzKnl2XbRs7bHZ3p6ECosQ" /> </LinearLayout>

的Andr​​oidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="schemas.android/apk/res/android" package="com.mapping" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".Mapping" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps" /> </application> </manifest>

谁能帮我?我拉我的头发一整天。该计划是好的运行,你可以看到我能够采取一个屏幕快照所以必须在设备到谷歌API的连接。我似乎无法找到错误...

Can anyone help me? I've pulling my hair all day. The program is running okay, as you can see I was able to take a screen shot so it must be the connection of the device to the Google API. I can't seem to find the error...

推荐答案

不要使用现有的地图API密钥或其他任何东西。你必须生成你的选择MD5指纹code自己的地图API密钥。只需看看下面的链接 -

Don't use existing map api key or anything else. You have to generate your own map api key with your md5 fingerprint code. Just have a look at below links -

  • Android的地图API密钥

    地图的API,注册

    看一看现有答案。而且,这里是一个最好的例如生成步骤一步的地图API密钥。这些可能帮助您肯定。

    Have a look at existing answer. And, here is a best example for generating map api key with step-by-step. These may helps you surely.

  • 更多推荐

    谷歌地图不显示任何地图

    本文发布于:2023-06-07 22:04:24,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/568593.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:地图

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!