I'm updating my app to support API 21 - Android 5.0.But Google maps do not work. I changed the getMap() to getMapAsync() and Google map is loaded but it doesn't display the pin. I can see only oceans:) but not coordinates specified on my code. Why can't I see the pin on the map? My code is below:
LatLng position = new LatLng(otelObject.getLatitude(),
otelObject.getLongitude());
orangeMarker = BitmapDescriptorFactory.fromResource(R.drawable.pin);
MarkerOptions marker = new MarkerOptions().position(position).icon(orangeMarker);
mMap.addMarker(marker);
CameraUpdate cameraUpdate = CameraUpdateFactory
.newLatLng(new LatLng(obj
.getLatitude(), obj
.getLongitude()));
mMap.moveCamera(cameraUpdate);
I'm debugging and i recognized that it doesn't setup the map.
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the
// map.
new SupportMapFragment() {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
this.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
setUpMap();
}
});
I called it onActivityCreated and on resume but I'm debugging and it is not going to setUpMap() but why?
Try adding
android:name="com.google.android.gms.maps.SupportMapFragment"
to your fragment.xml
And try using extend Fragment
instead of extend SupportMapFragment
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.