在Android中使用Google地图 - 错误代码 [英] Using Google Maps in Android - Error code
问题描述
我正在尝试学习本教程。
在Android中使用Google地图 - http://mobiforge.com/开发/故事/使用google-maps-android
我所做的第一个代码是:
package net.learn2develop.GoogleMaps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MapsActivity扩展MapActivity
{
/ **首次创建活动时调用。 * /
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed(){
return false;
}
}
我收到很多错误,如: p>
1)import.com.google无法解析。
2)MapActivity无法解析为类型。
请帮助我。谢谢
确定。我在 MapActivity类中的Mapview找不到中找到解决方案 / p>
您正在使用现在无法使用的旧版/弃用API。
您必须使用Google Maps V2 Api进行开发。
为此,您需要
- Google Play服务安装在您的SDK中( 阅读此信息 )。
- API API来自Google API控制台。
- 如果要开发Android 2.2(Froyo)及以上版本,您需要使用Supportmapfragment和fragmentActivity( 阅读这篇文章 )。
- 如果你想为Android 3.0(蜂巢)等开发,你必须使用Mapfragment和Activity( 阅读本文 )
请搜索SO论坛,在发布问题之前,有很多解决问题的相同问题
i was trying to learn this tutorial. Using Google Maps in Android-http://mobiforge.com/developing/story/using-google-maps-android
The first code that I did is :
package net.learn2develop.GoogleMaps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MapsActivity extends MapActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
Im getting a lot of error such as:
1) import.com.google cannot be resolved. 2) MapActivity cannot be resolved to a type.
Please help me. Thanks
OK. I FOUND THE SOLUTION IN Mapview in MapActivity Class not found
You are using the old/deprecated API which cannot be used now . You Have to use the Google Maps V2 Api for development. For this you need
- Google Play services install in your SDK(Read this Post).
- API key from the Google API Console.
- If you want to develop for android 2.2 (Froyo) and above you need to use the Supportmapfragment and fragmentActivity(Read This Post).
- If you want to develop for android 3.0(honeycomb) and above you have to use the Mapfragment and the Activity(Read This Post).
Please Search the SO forum before posting a question there are a lot of solved Questions regarding the Same Issue
这篇关于在Android中使用Google地图 - 错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!