安卓MapActivity:不能获得连接工厂客户端 [英] Android MapActivity : Couldn't get connection factory client

查看:124
本文介绍了安卓MapActivity:不能获得连接工厂客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让该地图演示工作,为谷歌API中提供 示例项目。我使用的AVDS和曾尝试与版本8,10 和11,并得到了同样的问题。

我已经生成自己的调试键添加到项目中。 我可以看到 在应用程序中的地图启动,并且可以在等放大 - 使我得到的地图 瓷砖,精致。 是的 - 我已经在清单中设置正确的权限和库 文件(根据样品)。

不过,我不能在地图上设置位置,或者通过DDMS或Telnet。 一世 看到LogCat中出现以下错误: MapActivity:不能获得连接工厂客户端

我读过很多关于这个问题的线程,但他们似乎总是 是一个坏API密钥的结果;而我没有,因为我 检索地图图块。

所以,我创建了自己的项目,这进一步测试,并正在执行 在我的地图初始化以下code:

  myLocationOverlay =新MyLocationOverlay(本,图形页面);
。调用MapView.getOverlays()加(myLocationOverlay);
myLocationOverlay.enableCompass();
myLocationOverlay.enableMyLocation();
Log.i(funkatron:,关于调用运行在第一次FIX);
myLocationOverlay.runOnFirstFix(新的Runnable(){
公共无效的run(){
字符串LOC =我们有一个位置,执行AnimateTo()。
+ myLocationOverlay.getMyLocation()的toString();
Log.i(funkatron:LOC);

mapController.animateTo(myLocationOverlay.getMyLocation());
}
});
 

我看到我的第一个日志声明,但从来没有第二个,MapActivity: 不能获得连接工厂客户端写入LogCat中那个 点。

我已阅读,有与SDK V8仿真器的问题,所以我有 试图与V10和11 - 但仍然没有喜悦。 我还没有尝试过这种在实际设备上 - 将马上要做

在这个问题上的任何帮助将不胜AP preciated - 这是真的 莫名其妙的我;)

欢呼声

解决方案

我有完全相同的初步情况。像你描述。

当看到地图上的瓷砖也有一些明显的缺失,看地图上的位置:

1。你需要的位置。 我认识到,通过DDMS视图设置只是一个地理位置到仿真器是不够的。你每次都明确地preSS的发送按钮,在DDMS来触发你的模拟器位置更新。 (只提:一个真实的你有时走位,使设备得到一个位置更新设备),我是如此生气,直到我走了一圈的现在做什么^^思维)

2。你需要有正确的OverlayItem 的正确实现ItemizedOverlay的。 我写我自己的叠加而得到了有点复杂。如果你不知道,如果你的实现是正确的,使用本指南创建具有最小的变化实现地图查看教程Android开发

或使用这样的:

 私有类MyItemizedOverlay扩展ItemizedOverlay {
    私人的ArrayList< OverlayItem> mOverlays =新的ArrayList< OverlayItem>();

    公共MyItemizedOverlay(可绘制defaultMarker){
          超(boundCenterBottom(defaultMarker));
    }

    公共无效addOverlay(OverlayItem叠加){
        mOverlays.add(叠加);
        填充();
    }

    @覆盖
    保护OverlayItem createItem中(int i)以{
      返回mOverlays.get(ⅰ);
    }

    @覆盖
    公众诠释大小(){
      返回mOverlays.size();
    }
}

私人无效updateLocationOverlay(){
    如果(位置== NULL){返回};
    名单<覆盖> mapOverlays =调用MapView.getOverlays();
    可绘制绘制= this.getResources()getDrawable(R.drawable.XXXX)。
    MyItemizedOverlay myItemizedOverlay =新MyItemizedOverlay(绘制);
    的GeoPoint点=新的GeoPoint((INT)(location.getLatitude()* 1E6),(INT)(location.getLongitude()* 1E6));

    OverlayItem overlayitem =新OverlayItem(点,霍拉,世界报!,我在墨西哥城!);
    myItemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(myItemizedOverlay);
}
 

我想特别指出的是,你必须调用boundCenter或boundCenterBottom上绘制。否则它不会被绘制。要也要注意,如果你在相同的覆盖与overlayItem.setMarker使用不同的标记,便u称之为有太多。

3。你要在地图上移动视图要贵点。你可以做到这一点是这样的:

  MapController mapController = mapView.getController();
mapController.setCenter(点)
 

我认识到功能的 mapController.zoomToSpan 的是行不通的。 (至少对我来说,我仍然在开发这个应用程序)。也许它的同的 animateTo 的。我没有尝试。集中心工作。 (和setZoom水平也)。

也许有东西在我提到的点,这可能会导致,那你的地图作品并不像你想要的。

祝你好运!

编辑:我忘了提,我仍然得到了工厂的客户端错误,甚至它的工作原理,以获得一个有效的位置,真正的器件和假模拟器上通过DDMS发送)。我只是忽略了。

I'm trying to get the Map demos working, as provided in the Google API sample projects.  I am using AVDs and have tried with versions 8, 10 and 11 and get the same issue.

I've generated my own debug key and added to the project.  I can see the map on app start up, and can zoom in etc - so I am getting the map tiles, fine. Yes - I have the correct permissions and  library set in the Manifest file (as per samples).

But, I cannot set a location on the map, either via DDMS or Telnet.  I see the following error in LogCat: MapActivity : Couldn't get connection factory client

I've read numerous threads regarding this issue, but they always seem to be as a result of a bad API key; which I do not have, as I am retrieving map tiles.

So I created my own project to test this further, and am executing the following code on initialisation of my map:

    myLocationOverlay = new MyLocationOverlay(this, mapView);
       mapView.getOverlays().add(myLocationOverlay);
       myLocationOverlay.enableCompass();
       myLocationOverlay.enableMyLocation();
       Log.i("funkatron: ", "ABOUT TO CALL RUN ON FIRST FIX");
       myLocationOverlay.runOnFirstFix(new Runnable() {
           public void run() {
               String loc = "we have a location, executing AnimateTo().
"+myLocationOverlay.getMyLocation().toString();
               Log.i("funkatron:",loc);

mapController.animateTo(myLocationOverlay.getMyLocation());
           }
       });

I see my first log statement, but never the second, and "MapActivity : Couldn't get connection factory client" is written to LogCat at that point.

I have read that there were issues with SDK v8 emulators, so I have tried with v10 and 11 - but still no joy. I have NOT yet tried this on an actual device - will do soon.

Any help on this issue would be greatly appreciated - it's really baffling me  ;)

cheers

解决方案

i had exactly the same initial situation as you described.

when you see the map tiles there are obviously some missing to see a position on the map:

1. you need a location. i recognized that setting only a geo position via DDMS view to the emulator is not enough. you have to explicitly press every time the "Send" button in DDMS to trigger a location update on your emulator. (just to mention: on a real the device you have sometimes to walk a bit to make your device get a location update ;), i was so pissed off until i walked around thinking of what to do now ^^)

2. you need a correct implementation of ItemizedOverlay with an correct OverlayItem. i wrote my own overlay which got bit "complicated". if you're not sure if your implementation is correct, use this guide to create an implementation with minimal changes Map view tutorial android developers

or use this:

private class MyItemizedOverlay extends ItemizedOverlay {
    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();

    public MyItemizedOverlay(Drawable defaultMarker) {
          super(boundCenterBottom(defaultMarker));
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    @Override
    protected OverlayItem createItem(int i) {
      return mOverlays.get(i);
    }

    @Override
    public int size() {
      return mOverlays.size();
    }
}

private void updateLocationOverlay() {
    if (location == null) { return };
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.XXXX);
    MyItemizedOverlay myItemizedOverlay = new MyItemizedOverlay(drawable);
    GeoPoint point = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6));

    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
    myItemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(myItemizedOverlay);
}

i want specially point out that you must call boundCenter or boundCenterBottom on the drawable. else it will not be drawn. be also careful if you use different markers in the same overlay with overlayItem.setMarker, that u call it there too.

3. you have to move the view on the map to your point. you can achieve this like this:

MapController mapController = mapView.getController();
mapController.setCenter(point)

i recognized that the function mapController.zoomToSpan does not work. (at least for me, i am still developing on this app). maybe its the same with animateTo. i did not try. set center works. (and setZoom level also).

Maybe there is something in the points i mentioned which could lead to, that your map does not work like you want.

Good luck!

edit: i forgot to mention that i am still getting that factory client error even it works to get a valid location, real on device and fake on emulator via ddms send). i just ignore for now.

这篇关于安卓MapActivity:不能获得连接工厂客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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