I want to ask about android app that I develop using google map in my apps. I already make multi marker on my map (1323 data so 1323 marker). So the question is:
I want to make search box to find specific marker on my map. I dont know how to find. Is it can find using title or snippet in marker
c = myDbHelper.query("Landslide", null, null, null, null,null, null);
if(c.moveToFirst()) {
do {
String loc = c.getString(3);
Double lat = c.getDouble(4);
Double lng = c.getDouble(5);
String date = c.getString(1);
//Integer death = c.getInt(6);
mMap.addMarker(new MarkerOptions()
.position(new LatLng(lat, lng))
.title(loc + "")
.snippet("Latitude:" + lat + " " + "Longitude:" + lng + " " + "Date:" + date + "")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.red1)));
} while (c.moveToNext());
}
}
Thanks In advance who helping me, regards, Hafizul Reza
I gess your markers data are stored in SQLite on your device. You can try to add a search box such as EditText, in your layout xml :
<EditText android:id="@+id/edit_textt_d" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
Then implement then onChange :
yourEditText = (EditText) findViewById(R.id.yourEditTextId);
yourEditTextaddTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
changeMarker(s)
}
});
On each change you should : delete the current marker of your map, query only markers that match the search box value :
public void changeMarker(String searchString) {
...
myGoogleMap.clear();
c=myDbHelper.getReadableDatabase().rawQuery("SELECT * FROM marker WHERE marker.name LIKE '"+searchString+"%'");
...
}
And then add your marker back on the map as you did in your question. Hope this help...