public class MainActivity extends FragmentActivity implements OnMapReadyCallback,
GoogleApiClient.OnConnectionFailedListener {
//google map object
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createLocationRequest();
//init google map fragment to show map.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Customize the map as needed
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// Add markers for Office with custom icon
Marker officeMarker = mMap.addMarker(new MarkerOptions()
.position(office) // i have added LatLang there
.title("Office"));
// Add markers for other locations with custom icons
// Example: shop
Marker shopMarker = mMap.addMarker(new MarkerOptions()
.position(shop) // i have added LatLang there
.title("Shop"));
}
}
Я создал это приложение Google Maps, оно работает нормально. Я добавил ключ API Google, который работает нормально.
Теперь, когда я нажимаю на любой маркер, добавленный на карту Google, приложение вылетает. Пожалуйста, помогите.
//init google map fragment to show map. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this);
}
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap;
// Customize the map as needed mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// Add markers for Office with custom icon Marker officeMarker = mMap.addMarker(new MarkerOptions() .position(office) // i have added LatLang there .title("Office"));
// Add markers for other locations with custom icons // Example: shop Marker shopMarker = mMap.addMarker(new MarkerOptions() .position(shop) // i have added LatLang there .title("Shop"));
}
} [/code] Я создал это приложение Google Maps, оно работает нормально. Я добавил ключ API Google, который работает нормально. Теперь, когда я нажимаю на любой маркер, добавленный на карту Google, приложение вылетает. Пожалуйста, помогите.