С этого утра я попытался собрать достаточно знаний, чтобы создать очень простое приложение для демонстрации концепции. Идея состоит в том, чтобы отобразить карты Google, пользователь нажимает туда, где он хочет добавить маркер, а затем появляется экран, где он может заполнить дополнительную информацию, которая затем отображается, когда кто-то нажимает на этот маркер.
Это то, что я получил от базы Android Studio.
public class MapsActivity extends FragmentActivity implements
OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
private void setMapLongClick(final GoogleMap map) {
map.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng latLng) {
}
});
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.z
* 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;
// Move the camera to Delft
LatLng delft = new LatLng(52.003569, 4.372987);
Float zoom = 15f;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(delft, zoom));
setMapLongClick(mMap);
}
}
Я пытался добавить это
private void setMarkerClick(final GoogleMap map) {
map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
Intent intent = new Intent(this, MainActivity.class);
this.startActivity(intent);
});
}
Но я получаю и ошибку "Недопустимый запуск типа". Я делаю это совершенно неправильно?
Есть ли более простой способ добавить информацию в маркер?