标记不是从mapV2机器人移除 [英] Marker is not removing from mapV2 android

查看:152
本文介绍了标记不是从mapV2机器人移除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在地图上的触摸添加制造商,想删除一些按钮的点击该标记,但该标记不是从地图。这里去除是我的code

I am adding a maker on touch of map and want to remove that marker on click of some button but that marker is not removing from map .Here is my Code

    // Marker of end Point
Marker endPointMarker;

地图的onclick

onclick of map

        @Override
public void onMapClick(LatLng point) {
    // TODO Auto-generated method stub
    double lat = point.latitude;
    double lng = point.longitude;

    // Add marker of destination point

            try {
                Geocoder geocoder;
                List<Address> addresses;
                geocoder = new Geocoder(BookCabScreen.this);
                if (lat != 0 || lng != 0) {
                    addresses = geocoder.getFromLocation(lat, lng, 1);
                    String address = addresses.get(0).getAddressLine(0);
                    String city = addresses.get(0).getAddressLine(1);
                    String country = addresses.get(0).getAddressLine(2);
                    Log.d("TAG", "address = " + address + ", city =" + city
                            + ", country = " + country);
                    endPointMarker = mMap.addMarker(new MarkerOptions()
                            .position(new LatLng(lat, lng))
                            .title("Location").snippet("" + address));

                    markers.add(mMap.addMarker(new MarkerOptions()
                            .position(new LatLng(lat, lng))
                            .title("Location").snippet("" + address)));
                    btnStartUp.setEnabled(true);
                    btnStopPoint.setEnabled(true);

                    mJbBookCab.setEndPointLat(lat);
                    mJbBookCab.setEndPointLng(lng);
                } else {
                    Toast.makeText(BookCabScreen.this,
                            "latitude and longitude are null",
                            Toast.LENGTH_LONG).show();

                }
            } catch (Exception e) {
                e.printStackTrace();

            }


}

按钮的点击

            if (endPointMarker != null) {
            endPointMarker.remove();

            endPointMarker = null;
        }

但它不会从地图上移除?请帮

But it is not removing from map ?Please help

推荐答案

您添加相同的标记两次:

You are adding same marker twice:

                endPointMarker = mMap.addMarker(new MarkerOptions()
                        .position(new LatLng(lat, lng))
                        .title("Location").snippet("" + address));

                markers.add(mMap.addMarker(new MarkerOptions()
                        .position(new LatLng(lat, lng))
                        .title("Location").snippet("" + address)));

只是删除​​一个调用 GoogleMap.addMarker

这篇关于标记不是从mapV2机器人移除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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