java - Android: MapView not showing up empty -


i want show google maps in tabbed layout
so created viewpager in main activity , added below fragment map
showing empty.

every overridden function getting called expected.
not able understand causing map not show up.

below code

fragment_map.xml

<?xml version="1.0" encoding="utf-8"?> <com.google.android.gms.maps.mapview     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:map="http://schemas.android.com/apk/res-auto"     android:name="com.google.android.gms.maps.supportmapfragment"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:apikey="@string/google_maps_key"      android:id="@+id/mapview" >  </com.google.android.gms.maps.mapview> 

mapfragment.java

    import android.os.bundle;     import android.support.v4.app.fragment;     import android.view.layoutinflater;     import android.view.view;     import android.view.viewgroup;      import com.google.android.gms.maps.cameraupdatefactory;     import com.google.android.gms.maps.googlemap;     import com.google.android.gms.maps.mapview;     import com.google.android.gms.maps.onmapreadycallback;     import com.google.android.gms.maps.model.latlng;     import com.google.android.gms.maps.model.markeroptions;     import com.i2e1.iconnect.r;      import java.util.arraylist;     import java.util.list;      public class mapfragment extends fragment implements onmapreadycallback {          mapview m;         googlemap googlemap;         private list<markeroptions> markers;          public mapfragment() {             // required empty public constructor         }          @override         public void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);         }          @override         public view oncreateview(layoutinflater inflater, viewgroup container,                                  bundle savedinstancestate) {             view v = inflater.inflate(r.layout.fragment_map, container, false);             m = (mapview) v.findviewbyid(r.id.mapview);             m.getmapasync(this);             m.oncreate(savedinstancestate);             return v;         }          @override         public void onresume() {             super.onresume();             m.onresume();         }          @override         public void onpause() {             super.onpause();             m.onpause();         }          @override         public void ondestroy() {             super.ondestroy();             m.ondestroy();         }          @override         public void onlowmemory() {             super.onlowmemory();             m.onlowmemory();         }          @override         public void onmapready(googlemap googlemap) {             this.googlemap = googlemap;             (markeroptions m : markers) {                 googlemap.addmarker(new markeroptions()                         .position(m.getposition())                         .title(m.gettitle()));             }             googlemap.animatecamera(cameraupdatefactory.newlatlngzoom(markers.get(0).getposition(), 15), 5000, null);             m.onresume();         } } 

here code. tried , works well. try this


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -