0
Good night, I have an application with a map in a Swipe tab, but I want the map to mark a point on the map and start at that point.
thanks in advance.
Together send the JAVA:
public class Mapa extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View android = inflater.inflate(R.layout.mapa_3, container, false);
return android;
}
@Override
public void onDestroyView() {
super.onDestroyView();
Fragment f = getFragmentManager().findFragmentById(R.id.mapFragment);
if (f != null)
getFragmentManager().beginTransaction().remove(f).commit();
}
}
and the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map_container"
tools:context=".Mapa" >
<fragment
android:id="@+id/mapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
How are you handling the instance of
GoogleMap
? To create a Marker just create oneMarkerOptions
and then pass it on toGoogleMap.createMarker
.– Wakim
But this is done in java?
– SaPires
That’s right, no
onCreate
ofActivity
or ofonCreateView
ofFragment
. Take a look at the first answer to this EN OS question: http://stackoverflow.com/questions/19353255/how-to-put-google-maps-v2-on-a-fragment-using-viewpager.– Wakim