Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.aidmaid;
- import android.app.Activity;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.v4.app.Fragment;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.webkit.WebSettings;
- import android.webkit.WebView;
- import com.google.android.gms.maps.GoogleMap;
- import com.google.android.gms.maps.MapView;
- import com.google.android.gms.maps.MapsInitializer;
- import com.google.android.gms.maps.SupportMapFragment;
- import com.google.android.gms.maps.model.BitmapDescriptorFactory;
- import com.google.android.gms.maps.model.GroundOverlayOptions;
- import com.google.android.gms.maps.model.LatLng;
- import com.google.android.gms.maps.model.LatLngBounds;
- import com.google.android.gms.maps.model.MarkerOptions;
- /**
- * A simple {@link Fragment} subclass.
- * Use the {@link CrimesMapFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
- public class CrimesMapFragment extends Fragment {
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- *
- * @return A new instance of fragment CrimesMapFragment.
- */
- // TODO: Rename and change types and number of parameters
- public static CrimesMapFragment newInstance() {
- CrimesMapFragment fragment = new CrimesMapFragment();
- return fragment;
- }
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState)
- {
- //Image view to rotate as a compass
- //setUpMapIfNeeded();
- }
- @Override
- public void onResume()
- {
- super.onResume();
- }
- public CrimesMapFragment() {
- // Required empty public constructor
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- //setUpMapIfNeeded();
- }
- private GoogleMap mMap; // Might be null if Google Play services APK is not available.
- private MapView mMapView; // Might be null if Google Play services APK is not available.
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View view = inflater.inflate(R.layout.fragment_crimes_map, container,
- false);
- WebView myBrowser = (WebView)view.findViewById(R.id.crimeMapWebView);
- WebSettings settings = myBrowser.getSettings();//.setJavaScriptEnabled(true);
- settings.setJavaScriptEnabled(true);
- settings.setAllowFileAccessFromFileURLs(true); //Maybe you don't need this rule
- settings.setAllowUniversalAccessFromFileURLs(true);
- myBrowser.loadUrl("file:///android_asset/crime.html");
- // mMapView = (MapView) view.findViewById(R.id.mapView);
- // mMapView.onCreate(savedInstanceState);
- //
- // mMapView.onResume();// needed to get the map to display immediately
- //
- // try {
- // MapsInitializer.initialize(getActivity().getApplicationContext());
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- //
- // mMap = mMapView.getMap();
- //
- // if(mMap == null)
- // return view;
- //
- // LatLngBounds leftNewarkBounds = new LatLngBounds(
- // new LatLng(-85, -180), // top left corner of map
- // new LatLng(85, 0)); // North east corner
- //
- // GroundOverlayOptions leftNewarkMap = new GroundOverlayOptions()
- // .image(BitmapDescriptorFactory.fromResource(R.drawable.crimes_map_left))
- // .positionFromBounds(leftNewarkBounds);
- // mMap.addGroundOverlay(leftNewarkMap);
- //
- // LatLngBounds rightNewarkBounds = new LatLngBounds(
- // new LatLng(-85, 0), // top left corner of map
- // new LatLng(85, 180)); // North east corner
- //
- // GroundOverlayOptions rightNewarkMap = new GroundOverlayOptions()
- // .image(BitmapDescriptorFactory.fromResource(R.drawable.crimes_map_right))
- // .positionFromBounds(rightNewarkBounds);
- // mMap.addGroundOverlay(rightNewarkMap);
- return view;
- }
- // TODO: Rename method, update argument and hook method into UI event
- public void onButtonPressed(Uri uri) {
- //if (mListener != null) {
- // mListener.onFragmentInteraction(uri);
- //}
- }
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- }
- @Override
- public void onDetach() {
- mMap = null;
- mMapView = null;
- super.onDetach();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement