在应用程序中,我将标记总数限制为50,之后用户应删除标记以便能够固定更多标记。现在我想禁止用户在很短的时间内固定大量的标记,我想让他每天只能固定2个标记。
代码到目前为止:
private GoogleMap mMap;
Marker marker; // Marker
int markerCount = 0; // Marker counter
//Add marker on long click
mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
int iMax = 50; // Max number of markers
@Override
public void onMapLongClick(LatLng arg0) {
if (markerCount < iMax) {
// start SendMessageActivity need to add marker to message activity
startActivity(new Intent(MapsActivity.this, SendMessageActivity.class));
markerCount = markerCount + 1;
marker = mMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker))
.position(
new LatLng(arg0.latitude,
arg0.longitude))
.visible(true));
} else {
Toast.makeText(getApplicationContext(), "Only " + iMax + " markers allowed at the same time",
Toast.LENGTH_LONG).show();
}
}
});