【问题标题】:Cant click the infowindow android google map v2无法点击信息窗口 android google map v2
【发布时间】:2013-04-22 06:02:47
【问题描述】:

我在点击窗口时遇到问题。

我的代码如下:

public class GamapA extends FragmentActivity implements OnInfoWindowClickListener{


Marker myMarkerOne;

Gmap gm;

  gm = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
             gm.setMapType(GoogleMap.MAP_TYPE_NORMAL);


 gm.setOnInfoWindowClickListener(this);

LatLng one = new LatLng(12.786608, 80.221916);

   myMarkerOne = gm.addMarker(new MarkerOptions()
            .position(one)
            .title("Test")
            .snippet("Testing")
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));       

@Override
    public void onInfoWindowClick(final Marker marker) 
{
        // TODO Auto-generated method stub
        if(marker.getPosition().equals(myMarkerOne))
        {

    Toast.makeText(GamapChF.this, "Hello",Toast.LENGTH_LONG)
    .show();
        }
    }

单击窗口时,我没有收到 toast 消息。在此先感谢。

【问题讨论】:

    标签: android android-layout android-intent android-widget android-webview


    【解决方案1】:

    它不会给你干杯,因为

    marker.getPosition() 给你点赞lat/lng: (23.06831002668264,72.58109997957945)(查看这个打印日志,比如Log.e("marker.getPosition()-->", "" + marker.getPosition());

    你正在传递:new LatLng(23.06831, 72.58110);

    如您所见,(23.06831002668264,72.58109997957945)(23.06831, 72.58110) 不相等。所以它永远不会给你Toast

    所以,我建议您使用 Title 进行比较或按摩,例如:

    if (marker.getTitle().equalsIgnoreCase("Start")) {
                Toast.makeText(showMaps.this, "You have click on start -->",
                        Toast.LENGTH_LONG).show();
                Log.e("marker.getPosition()-->", "" + marker.getPosition());
            }
    

    【讨论】:

      猜你喜欢
      • 2013-05-16
      • 2012-12-15
      • 2013-05-22
      • 2013-01-09
      • 1970-01-01
      • 1970-01-01
      • 2015-07-10
      • 2015-05-31
      • 2011-08-08
      相关资源
      最近更新 更多