Android Gmap v2:使用点击事件启动自定义InfoWindow

时间:2017-04-25 19:13:57

标签: java android gridview google-maps-android-api-2

如何将网格视图添加到InfoWindow并检测点击事件?

参见示例:

enter image description here

如果点击了gridview中的其中一个图标,我想将此图标添加到用户点击位置的地图上。

我用来显示弹出菜单的代码:

gMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
      @Override
      public void onMapLongClick(LatLng location) {
        //Create invisible marker and show custom Info Window
        MarkerOptions markerInvisible = new MarkerOptions().flat(false).title("Start").alpha(0.00f).infoWindowAnchor(0,1);
        markerInvisible.position(location);
        Marker invisibleMarker = gMap.addMarker(markerInvisible);
        invisibleMarker.showInfoWindow();

        contextmenu = true;
      }
    });

的GridView:

GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(new IconboxAdapter(this));

    final Context context = this;
    gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View v,
                              int position, long id) {
        Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show();
      }
    });

0 个答案:

没有答案