【问题标题】:Android: MapView does not react on touch events under some layers of WiFiSLAMAndroid:在WiFiSLAM的某些层下,MapView对触摸事件没有反应
【发布时间】:2012-12-28 06:52:16
【问题描述】:

我正在使用室内定位框架wifislam,有一个编程问题。 到目前为止,我已经通过WifiSLAM 的interiorLocationView 给出了一个MapView。我正在使用以下代码。

    final IndoorLocationManager.Configuration config = new IndoorLocationManager.Configuration();
    indoorLocationManager = new IndoorLocationManager(this, config,
            onServiceConnected, LOCATION_CHOICE);
    indoorLocationView = indoorLocationManager.createLocationView(this,
            GOOGLE_MAPS_API_KEY);

    final View mapContainer = findViewById(R.id.mapcontainer);
    ((ViewGroup) mapContainer).addView(indoorLocationView.getView());
    MapView mapView = indoorLocationView.getGoogleMapView();
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.pinred);
    itemizedOverlay = new AddItemizedOverlay(drawable, mapView.getContext(), sm);
    mapOverlays.add(itemizedOverlay);

AddItemizedOverlay 有以下方法:

@Override
public boolean onTap(GeoPoint geopoint, MapView mapView) {
    mapOverlays.clear();
    // geopoint = mapView.getProjection().fromPixels((int) event.getX(),
    // (int) event.getY());
    // latitude
    if (geopoint != null) {
        this.geopoint = geopoint;
        lat = geopoint.getLatitudeE6();
        // longitude
        lon = geopoint.getLongitudeE6();
        OverlayItem overlayitem = new OverlayItem(geopoint,
                "Task Position", "Derzeitige Position vom Task");
        this.addOverlay(overlayitem);
    }
    return false;
}

我现在的问题是,onTap 方法对触摸设备没有响应或反应。 onTouch 事件也没有反应。我认为 wifislam 上面的那些层阻止了我可以访问 MapView。是否有可能到达 MapView,以便我可以在地图上添加一些标记?

【问题讨论】:

    标签: android android-mapview


    【解决方案1】:

    这样做的原因是 Google 地图视图顶部有一个透明视图,用于显示平面图。尝试在 IndoorLocationView#getView 返回的视图上添加一个侦听器,但这可能会搞砸捏缩放/平移控件;你应该仔细检查一下效果(你可能想从你的听众那里返回 false ,除非你的标记之一被点击了)。

    如果这不起作用,您最好联系 WiFiSLAM 支持并提供您的用例,以便他们更新他们的 SDK 以满足您的需求。 SDK 网站帮助部分的 FAQ 主题中似乎有一个支持电子邮件地址。

    【讨论】:

      猜你喜欢
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多