进口com.google.maps.MapView不工作 [英] importing com.google.maps.MapView not working

查看:249
本文介绍了进口com.google.maps.MapView不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图做一个地图的例子,我发现在这里
http://$c$cmagician.word$p$pss.com/2010/05/06/android-google-mapview-tutorial-done-right/

问题是这样的code。具体来说,编译器似乎并不知道MapView的是什么?事实上,也适用于android.graphics.drawable.Drawable。我认为import语句会解决,但必须失去了一些其他的设置步骤。

任何帮助AP preciated。

 包com.example.HelloGoogleMaps2;
进口的java.util.List;
进口android.graphics.drawable.Drawable;
进口android.os.Bundle;
进口com.google.android.maps.GeoPoint;
进口com.google.android.maps.MapActivity;
进口com.google.android.maps.MapView;
进口com.google.android.maps.Overlay;
进口com.google.android.maps.OverlayItem;公共类MainMap扩展MapActivity
{
 @覆盖
 公共无效的onCreate(捆绑savedInstanceState)
 {
     super.onCreate(savedInstanceState);
     的setContentView(R.layout.main);     ** ** MapView类MapView类=(图形页面)findViewById(R.id.mapview);
     mapView.setBuiltInZoomControls(真);     清单<&叠加GT; mapOverlays =调用MapView.getOverlays();
     ** **可绘制可绘制= this.getResources()getDrawable(R.drawable.icon)。
     HelloItemizedOverlay itemizedoverlay =新HelloItemizedOverlay(绘制,这一点);
     的GeoPoint点=新的GeoPoint(30443769,-91158458);
     OverlayItem overlayitem =新OverlayItem(点,我在路易斯安那州!放任LES苯教临时工rouler!);     的GeoPoint点2 =新的GeoPoint(17385812,78480667);
     OverlayItem overlayitem2 =新OverlayItem(!Namashkaar点2,我在印度海得拉巴!);     itemizedoverlay.addOverlay(overlayitem);
     itemizedoverlay.addOverlay(overlayitem2);     mapOverlays.add(itemizedoverlay);
 }
 @覆盖
 保护布尔isRouteDisplayed()
 {
 返回false;
 }
}


解决方案

检查您的目标设备,当你创建新的项目。它应该是谷歌的API(谷歌公司) - API级别 - (任何你想要的)

作为医生说:你必须有一个 AVD 配置为使用谷歌的API 目标,或者使用显影装置,包括地图库。并确保您有Internet的权限

 <使用许可权的android:NAME =android.permission.INTERNET对/>

和作为默认的Andr​​oid库不包含图形页面,所以你需要
指定在AndroidManifest.xml

 <使用库机器人:名字=com.google.android.maps/>

这里是开始与谷歌的好地方地图

你确定你有

Trying to do a map example I found here http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/

The problem is this code. Specifically, the compiler does not seem to know what a MapView is? In fact, also applies to android.graphics.drawable.Drawable. I thought that the import statement would resolve that but must be missing some other setup step.

Any help appreciated.

package com.example.HelloGoogleMaps2;
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.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class MainMap extends MapActivity
{
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);

     **MapView** mapView = (MapView) findViewById(R.id.mapview);
     mapView.setBuiltInZoomControls(true);

     List<Overlay> mapOverlays = mapView.getOverlays();
     **Drawable** drawable = this.getResources().getDrawable(R.drawable.icon);
     HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);
     GeoPoint point = new GeoPoint(30443769,-91158458);
     OverlayItem overlayitem = new OverlayItem(point, "Laissez les bon temps rouler!", "I'm in Louisiana!");

     GeoPoint point2 = new GeoPoint(17385812,78480667);
     OverlayItem overlayitem2 = new OverlayItem(point2, "Namashkaar!", "I'm in Hyderabad, India!");

     itemizedoverlay.addOverlay(overlayitem);
     itemizedoverlay.addOverlay(overlayitem2);

     mapOverlays.add(itemizedoverlay);
 }
 @Override
 protected boolean isRouteDisplayed()
 {
 return false;
 }
}

解决方案

Check your target device when you create new project. It should be Google APIs(Google Inc.)-API Level -(whatever you want).

as doc says :"you must have an AVD configured to use the Google APIs target, or be using a development device that includes the Maps library".And make sure you have Internet Permission

<uses-permission android:name="android.permission.INTERNET"/>

and as MapView is not included in the default Android libraries, so you need to specify in AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />

and here is a good place to start with google maps

are you sure you have

这篇关于进口com.google.maps.MapView不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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