Android maps removing previous marker location tracking | بلاگ

Android maps removing previous marker location tracking

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I am trying to display marker on user position and remove the previous one.I have tried something like this but its not working.

LocationListener locationListener = new LocationListener() {
            public void onLocationChanged(Location location) {
                Toast.makeText(getActivity(), String.valueOf(location.getLatitude()),Toast.LENGTH_SHORT).show();



                Marker playermarker = null;
                if (playermarker!=null) {
                    playermarker.remove();
                    playermarker=null;
                }

                if (playermarker==null) {
                    playermarker = googleMap.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(),location.getLongitude())));

                }



            }

            public void onStatusChanged(String provider, int status, Bundle extras) {}

            public void onProviderEnabled(String provider) {}

            public void onProviderDisabled(String provider) {}
        };
asked 17 secs ago
lp879

...
نویسنده : استخدام کار بازدید : 9 تاريخ : سه شنبه 24 بهمن 1396 ساعت: 19:51