Так что я изо всех сил пытаюсь сделать так, чтобы это button
"btnFindCybercafe" работало. я просто хочу, чтобы button
показывал ближайшие marker
около 10км от текущего местоположения.
Ниже моя карта Java-код
public class mapCybercafe extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
protected GoogleMap LokasiUser;
private static final int LOCATION_REQUEST = 500;
protected Marker LokasiCybercafe;
final LatLng NOBLENATION = new LatLng(3.556744, 98.677177 );
final LatLng H2NET = new LatLng(3.534811, 98.591373 );
final LatLng BRITANNIA = new LatLng(3.572011, 98.698239 );
final LatLng ICAFEMEDAN = new LatLng(3.598079, 98.663644 );
final LatLng MILALAMAS = new LatLng(3.592356, 98.685277 );
final LatLng CYPRESSNET = new LatLng(3.555556, 98.633377 );
final LatLng LASVEGASNET = new LatLng(3.572083, 98.694061 );
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_map);
// Obtain the SupportMapFragment
final SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
mMap.clear();
Button btnAbout = findViewById(R.id.btn_about);
Button btnHelp = findViewById(R.id.btn_help);
Button btnFindCybercafe = findViewById(R.id.btn_FindCybercafe);
btnAbout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentAbout = new Intent(mapCybercafe.this, AboutActivity.class);
startActivity(intentAbout);
}
}
);
btnHelp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentAbout = new Intent(mapCybercafe.this, HelpActivity.class);
startActivity(intentAbout);
}
}
);
btnFindCybercafe.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick(View v) {
do {
}
}
}
);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LokasiUser = googleMap;
// realtime user location
LokasiUser.getUiSettings().setZoomControlsEnabled(true);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission
(this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST);
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LokasiUser.setMyLocationEnabled(true);
// Add a marker of cybercafe in layout
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(LASVEGASNET).title("Las Vegas Net CYBERCAFE").snippet("i5, 8GB RAM, Nvidia GEFORCE 1050"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(NOBLENATION).title("NOBLENATION CYBERCAFE").snippet("i5, 16GB RAM, Nvidia GEFORCE 1050Ti"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(H2NET).title("H2-NET CYBERCAFE").snippet("AMD RYZEN, 8GB RAM, Nvidia GEFORCE 1020Ti"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(BRITANNIA).title("BRITANNIA-NET CYBERCAFE").snippet("i3, 8GB RAM, Nvidia GEFORCE 980Ti"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(ICAFEMEDAN).title("iCAFE-MEDAN ").snippet("i3, 4GB RAM, Nvidia GEFORCE 980"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(MILALAMAS).title("MILALAMAS-NET CYBERCAFE").snippet("i5, 8GB RAM, Nvidia GEFORCE 1060Ti"));
LokasiCybercafe = googleMap.addMarker(new MarkerOptions()
.position(CYPRESSNET).title("CYPRESS-NET CYBERCAFE").snippet("i3, 4GB RAM, Nvidia GEFORCE 970"));
}
@SuppressLint("MissingPermission")
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case LOCATION_REQUEST:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
}
break;
}
}
}
Мне действительно нужен кто-то, чтобы помочь мне, потому что мой срок завтра.