I want to show fileds and attributes in popup when I clicked a point. But I get Null Pointer Exception. Why I return to me null? Can you help please? How can I do? I did like esri android sample. but it doesnt work.
/// long press to map
mapView.setOnLongPressListener(new OnLongPressListener() {
private static final long serialVersionUID = 1L;
// ArcGISFeatureLayer
private ArcGISFeatureLayer featureLay = null;
/// override onLongPress
#Override
public boolean onLongPress(final float v, final float v1) {
if (mapView.isLoaded()) {
if (progressDialog != null && progressDialog.isShowing()
&& count.intValue() == 0)
//dismiss dialog
progressDialog.dismiss();
// Get the point featurelayer
Layer[] layers = mapView.getLayers();
for (Layer layer : layers) {
if (layer instanceof ArcGISFeatureLayer) {
ArcGISFeatureLayer fl = (ArcGISFeatureLayer) layer;
if (fl.getGeometryType() == Geometry.Type.POINT) {
featureLay = fl;
break;
}
}
}
//// if featureLay null
if (featureLay == null)
return false;
ArcGISPopupInfo popupInfos = (ArcGISPopupInfo) featureLay.getPopupInfos();
///!!!!!!!!!!!!!!! return to me null////////////
if (popupInfos == null)
return false;
// Create a new feature
Point point = mapView.toMapPoint(v, v1);
Feature feature2;
FeatureType[] types = featureLay.getTypes();
if (types == null || types.length < 1) {
FeatureTemplate[] templates = featureLay
.getTemplates();
if (templates == null || templates.length < 1) {
feature2 = new Graphic(point, null);
} else {
feature2 = featureLay.createFeatureWithTemplate(
templates[0], point);
}
} else {
feature2 = featureLay.createFeatureWithType(
featureLay.getTypes()[0], point);
}
// Instantiate a PopupContainer
popupContainer = new PopupContainer(mapView);
// popup create
Popup popupp = featureLay.createPopup(mapView, 0, feature2);
popupContainer.addPopup(popupp);
popupp.setEditMode(true);
createEditorBar(featureLay, false);
// Create a dialog for the popups and display it.
popupDialog = new PopupDialog(mapView.getContext(),
popupContainer);
// show popup
popupDialog.show();
}
return true;
}
});
Related
I have a Xamarin Forms project on visual studio 2019.
I wanted to hide the cancel button from a simple Picker but wasn't able to do so, so I have now a custom picker but don't know how to remove that button. Either that or changing the "Cancel" button for an "Ok" would be what I want.
The thing is the examples that I have seen are customizing this by using the NumberPicker class and this won't work for me as I don't want to display my list that way.
My CustomPicker class
public class CustomPicker : Picker
{
public static readonly BindableProperty ImageProperty =
BindableProperty.Create(nameof(Image), typeof(string), typeof(CustomPicker), string.Empty);
public string Image
{
get { return (string)GetValue(ImageProperty); }
set { SetValue(ImageProperty, value); }
}
}
My CustomPickerRenderer class on Android project
public class CustomPickerRenderer : Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer
{
public CustomPickerRenderer(Context context) : base(context) { }
CustomPicker element;
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
element = (CustomPicker)this.Element;
if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image))
{
Control.Background = AddPickerStyles(element.Image);
Control.Gravity = GravityFlags.CenterHorizontal;
}
}
public LayerDrawable AddPickerStyles(string imagePath)
{
ShapeDrawable border = new ShapeDrawable();
border.Paint.Color = Android.Graphics.Color.Gray;
border.SetPadding(10, 10, 10, 10);
border.Paint.SetStyle(Paint.Style.Stroke);
Drawable[] layers = { border, GetDrawable(imagePath) };
LayerDrawable layerDrawable = new LayerDrawable(layers);
layerDrawable.SetLayerInset(0, 0, 0, 0, 0);
return layerDrawable;
}
private BitmapDrawable GetDrawable(string imagePath)
{
int resID = Resources.GetIdentifier(imagePath, "drawable", this.Context.PackageName);
var drawable = ContextCompat.GetDrawable(this.Context, resID);
var bitmap = ((BitmapDrawable)drawable).Bitmap;
var result = new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, 70, 70, true));
result.Gravity = Android.Views.GravityFlags.Right;
return result;
}
}
My CustomPickerRenderer on iOS project
public class CustomPickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
var element = (CustomPicker)this.Element;
if (this.Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image))
{
var downarrow = UIImage.FromBundle(element.Image);
Control.RightViewMode = UITextFieldViewMode.Always;
Control.RightView = new UIImageView(downarrow);
Control.TextAlignment = UITextAlignment.Center;
}
}
}
How can I achieve this? Please help and thanks.
You can set a donetextproperty in your picker and set it in the uibuttontext on ios side.like:
public class MyPicker:Picker
{
public static readonly BindableProperty DonebuttonTextProperty = BindableProperty.Create("DonebuttonText", typeof(string),
typeof(string), null);
public string DonebuttonText { get { return (string)GetValue(DonebuttonTextProperty); }
set { SetValue(DonebuttonTextProperty, value); }
}
public MyPicker()
{
}
}
}
iOSRenderer:
public class MyPickerRenderer:PickerRenderer
{
public MyPickerRenderer()
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (e.NewElement == null) return;
var customPicker = e.NewElement as MyPicker;
if (Control == null)
{
SetNativeControl(new UITextField
{
RightViewMode = UITextFieldViewMode.Always,
ClearButtonMode = UITextFieldViewMode.WhileEditing
});
SetUIbutton(customPicker.DonebuttonText);
}
else
{ SetUIbutton(customPicker.DonebuttonText); }
}
public void SetUIbutton(string doneButtonText)
{
UIToolbar toolbar = new UIToolbar();
toolbar.BarStyle = UIBarStyle.Default;
toolbar.Translucent = true;
toolbar.SizeToFit();
UIBarButtonItem doneButton = new UIBarButtonItem(string.IsNullOrEmpty(doneButtonText) ? "OK" : doneButtonText,
UIBarButtonItemStyle.Done, (s, ev) => { Control.ResignFirstResponder(); });
UIBarButtonItem flexible = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
toolbar.SetItems(new UIBarButtonItem[] { doneButton, flexible }, true);
Control.InputAccessoryView = toolbar;
}
}
As for android, change text in NegativeButton like:
public class MyPickerRenderer : PickerRenderer
{
public MyPickerRenderer(Context context) : base(context)
{
}
private IElementController ElementController => Element as IElementController;
private AlertDialog _dialog;
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (e.NewElement == null || e.OldElement != null)
return;
Control.Click += Control_Click;
}
protected override void Dispose(bool disposing)
{
Control.Click -= Control_Click;
base.Dispose(disposing);
}
private void Control_Click(object sender, EventArgs e)
{
Picker model = Element;
var picker = new NumberPicker(Context);
if (model.Items != null && model.Items.Any())
{
picker.MaxValue = model.Items.Count - 1;
picker.MinValue = 0;
picker.SetDisplayedValues(model.Items.ToArray());
picker.WrapSelectorWheel = false;
picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
picker.Value = model.SelectedIndex;
}
var layout = new LinearLayout(Context) { Orientation = Orientation.Vertical };
layout.AddView(picker);
ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);
var builder = new AlertDialog.Builder(Context);
builder.SetView(layout);
builder.SetTitle(model.Title ?? "");
builder.SetNegativeButton("OK ", (s, a) =>
{
ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
// It is possible for the Content of the Page to be changed when Focus is changed.
// In this case, we'll lose our Control.
Control?.ClearFocus();
_dialog = null;
});
builder.SetPositiveButton("Done", (s, a) =>
{
ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
// It is possible for the Content of the Page to be changed on SelectedIndexChanged.
// In this case, the Element & Control will no longer exist.
if (Element != null)
{
if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
Control.Text = model.Items[Element.SelectedIndex];
ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
// It is also possible for the Content of the Page to be changed when Focus is changed.
// In this case, we'll lose our Control.
Control?.ClearFocus();
}
_dialog = null;
});
_dialog = builder.Create();
_dialog.DismissEvent += (ssender, args) =>
{
ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
};
_dialog.Show();
}
}
}
I am showing my own AlertDialog. It works and shows fine in most cases but in when I call from the following activity it does not show on UI. The code executes completely with no exceptions, I have even checked my logs and with breakpoints, Did not find any issue. But the dialog does not appear on UI. Can anyone tell me what the problem might be?
This is the method in my activity that calls the dialog.
private void showCustomDialog(final int messageType,
final String titleString,
final String msgString,
final String specificMsgString,
final int positiveButtonString,
final int negativeButtonString,
final Runnable positiveButtonClickHandler,
final Runnable negativeButtonClickHandler) {
if (mDialog != null && mDialog.isShowing()) {
Log.d(TAG, "showCustomDialog: cannot display two dialogs at once.");
return;
}
runOnUiThread(() -> mDialog = DialogUtil.showDialog(this, mAlertDialogBuilder, 0, messageType, titleString, msgString,
specificMsgString, positiveButtonString, negativeButtonString, positiveButtonClickHandler, negativeButtonClickHandler));
}
DialogUtil.showDialog method:
public static AlertDialog showDialog(
Activity activity,
AlertDialog.Builder builder,
final int borderTopColorRes,
final int iconRes,
final String titleString,
final String msgString,
final String specificMsgString,
final int positiveButtonString,
final int negativeButtonString,
final Runnable positiveButtonClickHandler,
final Runnable negativeButtonClickHandler) {
final DialogCustomViewBinding binding = DataBindingUtil.inflate(LayoutInflater.from(activity), R.layout.dialog_custom_view, null, false);
binding.textSpecificMessage.setVisibility(View.GONE);
if (borderTopColorRes != 0) {
binding.viewBorderTop.setBackgroundColor(borderTopColorRes);
} else {
binding.viewBorderTop.setVisibility(View.GONE);
}
if (iconRes != 0) {
binding.imageCustomDialogMessageType.setImageResource(iconRes);
}
if (titleString != null) {
binding.textCustomDialogTitle.setText(titleString);
binding.textCustomDialogTitle.setVisibility(View.VISIBLE);
} else {
binding.textCustomDialogTitle.setText("");
binding.textCustomDialogTitle.setVisibility(View.GONE);
}
if (msgString != null) {
binding.textDialogMessage.setText(msgString);
binding.textDialogMessage.setVisibility(View.VISIBLE);
} else {
binding.textDialogMessage.setText("");
binding.textDialogMessage.setVisibility(View.GONE);
}
binding.textSpecificMessage.setVisibility(View.GONE);
if (specificMsgString != null) {
binding.textSpecificMessage.setText(specificMsgString);
binding.textDialogMessage.setOnClickListener(v -> {
if (binding.textSpecificMessage.getVisibility() == View.VISIBLE) {
binding.textSpecificMessage.setVisibility(View.GONE);
} else {
binding.textSpecificMessage.setVisibility(View.VISIBLE);
}
});
}
if (positiveButtonClickHandler != null) {
binding.buttonPositive.setText(positiveButtonString);
binding.buttonPositive.setOnClickListener(v -> positiveButtonClickHandler.run());
} else {
binding.buttonPositive.setVisibility(View.GONE);
}
if (negativeButtonClickHandler != null) {
binding.buttonNegative.setText(negativeButtonString);
binding.buttonNegative.setOnClickListener(v -> negativeButtonClickHandler.run());
} else {
binding.buttonNegative.setVisibility(View.GONE);
}
builder.setView(binding.getRoot());
AlertDialog dialog = builder.create();
try {
dialog.show();
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
return dialog;
} catch (Exception e) {
Log.e(TAG, "showDialog: Exception=" + e.getMessage());
e.printStackTrace();
}
return null;
}
Guys I'm using Unity and Watson to make and vr app that accepts voice commands. I'm using the ExampleStreaming.cs provided with the asset but the recognition is terrible. I change the language model to Portuguese on the code. I'm using Samsung galaxy s7 on gear vr with the mic plugged in. I guess the app is using the cellphone mic and not the plugged one. Any help here.
Here's the code
private int _recordingRoutine = 0;
private string _microphoneID = null;
private AudioClip _recording = null;
private int _recordingBufferSize = 1;
private int _recordingHZ = 22050;
private SpeechToText _service;
public GolemController GolemControllerObj;
void Start()
{
LogSystem.InstallDefaultReactors();
Runnable.Run(CreateService());
}
private IEnumerator CreateService()
{
// Create credential and instantiate service
Credentials credentials = null;
if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
{
// Authenticate using username and password
credentials = new Credentials(_username, _password, _serviceUrl);
}
else if (!string.IsNullOrEmpty(_iamApikey))
{
// Authenticate using iamApikey
TokenOptions tokenOptions = new TokenOptions()
{
IamApiKey = _iamApikey,
IamUrl = _iamUrl
};
credentials = new Credentials(tokenOptions, _serviceUrl);
// Wait for tokendata
while (!credentials.HasIamTokenData())
yield return null;
}
else
{
throw new WatsonException("Please provide either username and password or IAM apikey to authenticate the service.");
}
_service = new SpeechToText(credentials);
_service.StreamMultipart = true;
_service.RecognizeModel="pt-BR_BroadbandModel";
Active = true;
StartRecording();
}
public bool Active
{
get { return _service.IsListening; }
set
{
if (value && !_service.IsListening)
{
_service.DetectSilence = true;
_service.EnableWordConfidence = true;
_service.EnableTimestamps = true;
_service.SilenceThreshold = 0.01f;
_service.MaxAlternatives = 0;
_service.EnableInterimResults = true;
_service.OnError = OnError;
_service.InactivityTimeout = -1;
_service.ProfanityFilter = false;
_service.SmartFormatting = true;
_service.SpeakerLabels = false;
_service.WordAlternativesThreshold = null;
_service.StartListening(OnRecognize, OnRecognizeSpeaker);
}
else if (!value && _service.IsListening)
{
_service.StopListening();
}
}
}
private void StartRecording()
{
if (_recordingRoutine == 0)
{
UnityObjectUtil.StartDestroyQueue();
_recordingRoutine = Runnable.Run(RecordingHandler());
}
}
private void StopRecording()
{
if (_recordingRoutine != 0)
{
Microphone.End(_microphoneID);
Runnable.Stop(_recordingRoutine);
_recordingRoutine = 0;
}
}
private void OnError(string error)
{
Active = false;
Log.Debug("ExampleStreaming.OnError()", "Error! {0}", error);
}
private IEnumerator RecordingHandler()
{
Log.Debug("ExampleStreaming.RecordingHandler()", "devices: {0}", Microphone.devices);
_recording = Microphone.Start(_microphoneID, true, _recordingBufferSize, _recordingHZ);
yield return null; // let _recordingRoutine get set..
if (_recording == null)
{
StopRecording();
yield break;
}
bool bFirstBlock = true;
int midPoint = _recording.samples / 2;
float[] samples = null;
while (_recordingRoutine != 0 && _recording != null)
{
int writePos = Microphone.GetPosition(_microphoneID);
if (writePos > _recording.samples || !Microphone.IsRecording(_microphoneID))
{
Log.Error("ExampleStreaming.RecordingHandler()", "Microphone disconnected.");
StopRecording();
yield break;
}
if ((bFirstBlock && writePos >= midPoint)
|| (!bFirstBlock && writePos < midPoint))
{
// front block is recorded, make a RecordClip and pass it onto our callback.
samples = new float[midPoint];
_recording.GetData(samples, bFirstBlock ? 0 : midPoint);
AudioData record = new AudioData();
record.MaxLevel = Mathf.Max(Mathf.Abs(Mathf.Min(samples)), Mathf.Max(samples));
record.Clip = AudioClip.Create("Recording", midPoint, _recording.channels, _recordingHZ, false);
record.Clip.SetData(samples, 0);
_service.OnListen(record);
bFirstBlock = !bFirstBlock;
}
else
{
// calculate the number of samples remaining until we ready for a block of audio,
// and wait that amount of time it will take to record.
int remaining = bFirstBlock ? (midPoint - writePos) : (_recording.samples - writePos);
float timeRemaining = (float)remaining / (float)_recordingHZ;
yield return new WaitForSeconds(timeRemaining);
}
}
yield break;
}
private void OnRecognize(SpeechRecognitionEvent result, Dictionary<string, object> customData)
{
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence);
Log.Debug("ExampleStreaming.OnRecognize()", text);
ResultsField.text = text;
if(res.final == true)
{
GolemControllerObj.GolemActions(alt.transcript);
}
}
if (res.keywords_result != null && res.keywords_result.keyword != null)
{
foreach (var keyword in res.keywords_result.keyword)
{
Log.Debug("ExampleStreaming.OnRecognize()", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
}
}
if (res.word_alternatives != null)
{
foreach (var wordAlternative in res.word_alternatives)
{
Log.Debug("ExampleStreaming.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time);
foreach(var alternative in wordAlternative.alternatives)
Log.Debug("ExampleStreaming.OnRecognize()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence);
}
}
}
}
}
private void OnRecognizeSpeaker(SpeakerRecognitionEvent result, Dictionary<string, object> customData)
{
if (result != null)
{
foreach (SpeakerLabelsResult labelResult in result.speaker_labels)
{
Log.Debug("ExampleStreaming.OnRecognize()", string.Format("speaker result: {0} | confidence: {3} | from: {1} | to: {2}", labelResult.speaker, labelResult.from, labelResult.to, labelResult.confidence));
}
}
}
I add an item for the progressBar at the end for loading more, and when load finish, I remove this item before adding element at the end of adapter.
But the the item is not correctly removed.
if (arrayAdapter != null) {
arrayAdapter.list.add(null);
arrayAdapter.notifyItemInserted(arrayAdapter.getItemCount() - 1);
arrayAdapter.notifyItemRangeChanged(arrayAdapter.getItemCount(), arrayAdapter.getItemCount());
}
serverRequests.getQuestionsAnsweredInBackground(userID, type, startLoad, new GetQuestionCallBack() {
#Override
public void done(ArrayList<Question> questions) {
if (arrayAdapter != null) {
arrayAdapter.list.remove(arrayAdapter.getItemCount() - 1);
arrayAdapter.notifyItemRemoved(arrayAdapter.getItemCount());
arrayAdapter.notifyItemRangeChanged(arrayAdapter.getItemCount(), arrayAdapter.getItemCount());
}
if (questions != null) {
if (arrayAdapter == null) {
arrayAdapter = new QuestionsAnsweredAdapter(getActivity(), R.layout.layout_questions_answered_item, questions, QuestionsAnswered.this);
lvQuestionsAnswered.setAdapter(arrayAdapter);
listLayout.setVisibility(View.VISIBLE);
} else {
final int positionStart = arrayAdapter.getItemCount();
arrayAdapter.list.addAll(questions);
arrayAdapter.notifyItemRangeInserted(positionStart, questions.size());
}
startLoad += questions.size();
loading = true;
}
progressBar.setVisibility(View.GONE);
}
});
Before loading new data
if(!mIsloading)
{
arrayAdapter.list.add(null);
arrayAdapter.notifyItemInserted(arrayAdapter.list.size() - 1);
mIsloading = true;
}
After done with fetching data
serverRequests.getQuestionsAnsweredInBackground(userID, type, startLoad, new GetQuestionCallBack() {
#Override
public void done(ArrayList<Question> questions) {
if (arrayAdapter.list.size() > 0 && arrayAdapter.list.get(arrayAdapter.list.size() - 1) == null) {
arrayAdapter.list.remove(arrayAdapter.list.size() - 1);
arrayAdapter.list.notifyItemRemoved(arrayAdapter.list.size());
}
mIsloading = false;
}
I am using mapbox sdk for offline map, i have added markers like
public void parseStops(String type) {
if (type.equals(activity.getResources().getString(R.string.allStops))) {
alStops = stopsOperations.selectData("walking");
} else {
Log.d("RouteType:", ":" + type);
alStops = stopsOperations.selectDataByType(type);
}
if (alStops.size() > 0) {
for (int i = 0; i < alStops.size(); i++) {
stopsEntity = new StopsEntity();
stopsEntity = alStops.get(i);
title = stopsEntity.getTitle();
lonngt = stopsEntity.getLongitude();
lat = stopsEntity.getLattitude();
routeType = stopsEntity.getType();
stopNumber = stopsEntity.getStopNumber();
Log.d("stopNumber:", ":" + stopNumber);
marker = new Marker(stopsEntity.getTitle(), "", new LatLng(
Double.parseDouble(stopsEntity.getLattitude()),
Double.parseDouble(stopsEntity.getLongitude())));
View view = ((LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.custom_marker_layout, null);
ivPin = (ImageView) view.findViewById(R.id.ivPin);
tvStopNumber = (TextView) view.findViewById(R.id.tvStopNumber);
if (routeType != null) {
if (routeType.equals(activity.getResources().getString(
R.string.walking1))
&& ((alStops.get(i).getStopNumber().equals("79"))
|| (alStops.get(i).getStopNumber()
.equals("98"))
|| (alStops.get(i).getStopNumber()
.equals("99")) || (alStops.get(i)
.getStopNumber().equals("125")))) {
ivPin.setImageResource(R.drawable.walking);
} else if (routeType.equals(activity.getResources()
.getString(R.string.red))) {
ivPin.setImageResource(R.drawable.pin_red);
} else if (routeType.equals(activity.getResources()
.getString(R.string.blue))) {
ivPin.setImageResource(R.drawable.blue_pin);
} else if (routeType.equals(activity.getResources()
.getString(R.string.orange))) {
ivPin.setImageResource(R.drawable.pin_orange);
} else if (routeType.equals(activity.getResources()
.getString(R.string.yellow))) {
ivPin.setImageResource(R.drawable.pin_yellow);
} else if (routeType.equals(activity.getResources()
.getString(R.string.lilac))) {
ivPin.setImageResource(R.drawable.pin_lilac);
} else if (routeType.equals(activity.getResources()
.getString(R.string.interchangee))) {
ivPin.setImageResource(R.drawable.pin_interchange);
}
}
if (stopNumber != null) {
if (stopNumber.length() < 2) {
tvStopNumber.setText("0" + stopNumber.toString());
} else {
tvStopNumber.setText(stopNumber.toString());
}
}
if (routeType != null
&& (alStops.get(i).getTitle().equalsIgnoreCase(activity
.getResources().getString(R.string.start)))
|| (alStops.get(i).getTitle().equalsIgnoreCase(activity
.getResources().getString(R.string.end)))) {
marker.setMarker(new BitmapDrawable(UDF
.createDrawableFromView1(activity, view)));
} else {
marker.setMarker(new BitmapDrawable(UDF
.createDrawableFromView1(activity, view)));
}
mv.addMarker(marker);
if (routeType != null
&& !routeType.equals(activity.getResources().getString(
R.string.walking1))) {
marker = new Marker(stopsEntity.getTitle(), "", new LatLng(
Double.parseDouble(stopsEntity.getLattitude()),
Double.parseDouble(stopsEntity.getLongitude())));
marker.setMarker(activity.getResources().getDrawable(
R.drawable.bus));
mv.addMarker(marker);
}
}
}
}
After that i need to remove these all added markers for some cases.
So, how can i remove all the markers simultaneously.
Can any one help me?
The MapView class has a method called clear:
void clear() Remove all markers from the map's display.
https://www.mapbox.com/mapbox-android-sdk/api/0.7.0/com/mapbox/mapboxsdk/views/MapView.html#clear()
For mapbox-android-sdk:3.0.0, the method is:
mMapView.removeAllAnnotations();
And, the .clear() method is no more.