Skip to content

Instantly share code, notes, and snippets.

@nuhkoca
Created January 7, 2018 15:05
Show Gist options
  • Save nuhkoca/c8459faef871857bed01fd67644c4918 to your computer and use it in GitHub Desktop.
Save nuhkoca/c8459faef871857bed01fd67644c4918 to your computer and use it in GitHub Desktop.
public class MapsFragment extends Fragment implements OnMapReadyCallback {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_maps, container, false);
SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager().
findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
if (getActivity()!=null)
CheckConnection.CheckConn(getActivity().getApplicationContext(), rootView);
return rootView;
}
@Override
public void onMapReady(GoogleMap googleMap) {
try {
// Add a marker in Sydney and move the camera
LatLng kanalAvrupa = new LatLng(51.449930, 6.738619);
googleMap.addMarker(new MarkerOptions().position(kanalAvrupa).title(getString(R.string.kaih)).snippet(getString(R.string.snippet_str))).showInfoWindow();
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(kanalAvrupa)
.zoom(18.3f)
.tilt(30)
.build();
googleMap.moveCamera(CameraUpdateFactory.newLatLng(kanalAvrupa));
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
} catch (Exception e) {
Toast.makeText(getActivity(), R.string.nomap, Toast.LENGTH_LONG).show();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment