package fishrungames.bashgid;


import com.google.android.gms.maps.GoogleMap;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import fishrungames.bashgid.core.LocationHolder;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class MapHolderFragment extends Fragment implements OnMapReadyCallback
{
	
	GoogleMap mMap = null;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			
		View rootView = inflater.inflate(R.layout.fragment_map_page, container, false);
			
		SupportMapFragment  mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map);
		
		mapFragment.getMapAsync(this);

		
		return rootView;
	}

	@Override
	public void onMapReady(GoogleMap map)
	{
		mMap = map;
		mMap.setMyLocationEnabled(true);
		mMap.getUiSettings().setRotateGesturesEnabled(false);
		
		mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE), LocationHolder.CONST_UFA_ZOOM));

		
		LatLng ufaPanoramas = new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
		/*Marker marker =*/ mMap.addMarker(new MarkerOptions()
		                          .position(ufaPanoramas)
		                          .title("Ufa")
		                          .snippet("City center"));
		

		mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener()
		{

			@Override
			public void onInfoWindowClick(Marker marker)
			{
				MainActivity.getInstance().OpenStreetViewScreen(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
			}
			
		});

		
	}
}
