Java 类com.google.android.gms.maps.MapsInitializer 实例源码

项目:ExtraMapUtils    文件:BasicFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    MapsInitializer.initialize(getActivity());
    final ViewOption viewOption = getViewOption();
    calculateAreaAndLength(viewOption);
    MapUtils.showElements(viewOption, googleMap, getActivity());
    googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            Bundle args = new Bundle();
            args.putParcelable("optionView", viewOption);
            Intent intent = new Intent(getActivity(), MapsActivity.class);
            intent.putExtra("args", args);
            startActivity(intent);
        }
    });
}
项目:RoadLab-Pro    文件:BaseStartMeasurementMapFragment.java   
protected void initMap(GoogleMap map) {
    goToLocation = true;
    firstLocationRefresh = true;
    if (map != null) {
        MapsInitializer.initialize(getActivity());
        RAApplication.getInstance().getGpsDetector().setGpsMapListener(new GPSDetector.GpsMapListener() {
            @Override
            public void onGpsMapListener(final Location location) {
                ActivityUtil.runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        if (refreshMyLocation) {
                            setCurrentLocation(location);
                        }
                    }
                });
            }
        });
        clearMap();
        LatLng loc = new LatLng(Constants.LATITUDE_BELARUS, Constants.LONGITUDE_BELARUS);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, Constants.DEFAULT_CAMERA_ZOOM));
        refreshMyLocation(loc);
        initMapData();
    }
}
项目:RoadLab-Pro    文件:BaseMapFragment.java   
protected void initMap(GoogleMap map) {
    goToLocation = true;
    firstLocationRefresh = true;
    if (map != null) {
        MapsInitializer.initialize(getActivity());
        RAApplication.getInstance().getGpsDetector().setGpsMapListener(new GPSDetector.GpsMapListener() {
            @Override
            public void onGpsMapListener(final Location location) {
                ActivityUtil.runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        if (refreshMyLocation) {
                            setCurrentLocation(location);
                        }
                    }
                });
            }
        });
        clearMap();
        LatLng loc = new LatLng(Constants.LATITUDE_BELARUS, Constants.LONGITUDE_BELARUS);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, Constants.DEFAULT_CAMERA_ZOOM));
        refreshMyLocation(loc);
        initMapData();
    }
}
项目:Bloop    文件:BootprintMapFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_bootprint_map, container, false);

    ButterKnife.bind(this, view);

    MapsInitializer.initialize(getActivity());
    mMapView.onCreate(savedInstanceState);

    // init bootprints
    //TOmaybeDO better data structure for this
    mBootprintLocations = new ArrayList<>(MAX_BOOTPRINTS);

    mLeftBootprint = BitmapDescriptorFactory.fromResource(R.drawable.bootprint_left);
    mRightBootprint = BitmapDescriptorFactory.fromResource(R.drawable.bootprint_right);

    // init map
    mHasSetInitialCameraPosition = false;

    mMapView.getMapAsync(this);

    return view;
}
项目:gps-measurement-tools    文件:MapFragment.java   
@Override
public View onCreateView(
    LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View rootView = inflater.inflate(R.layout.map_fragment, container, false);
  mMapView = ((MapView) rootView.findViewById(R.id.map));
  mMapView.onCreate(savedInstanceState);
  mMapView.getMapAsync(this);
  MapsInitializer.initialize(getActivity());

  RealTimePositionVelocityCalculator currentPositionVelocityCalculator =
      mPositionVelocityCalculator;
  if (currentPositionVelocityCalculator != null) {
    currentPositionVelocityCalculator.setMapFragment(this);
  }

  return rootView;
}
项目:Japp16    文件:Japp.java   
@Override
public void onCreate() {
    super.onCreate();
    instance = this;

    if (!FirebaseApp.getApps(this).isEmpty()) {
        analytics = FirebaseAnalytics.getInstance(this);
    }

    MapsInitializer.initialize(this);

    Deelgebied.initialize(this.getResources());

    AppData.initialize(this.getFilesDir());
    File dir = this.getFilesDir();
    String file = dir.getAbsolutePath();
    dir.exists();
}
项目:CellularNetworkMonitor    文件:MapFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.location_fragment, container, false);

    mMapView = (MapView) rootView.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();
    }

    mMapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap mMap) {
            googleMap = mMap;
            refreshMap(null);
        }
    });

    return rootView;
}
项目:gaso    文件:MapGasoFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_map, container, false);

    mapView = (MapView) v.findViewById(R.id.map);
    mapView.onCreate(savedInstanceState);

    mapView.onResume();// needed to get the googleMap to display immediately

    try {
        MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
        e.printStackTrace();
    }

    mapView.getMapAsync(this);

    progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
    emptyListTextView = (TextView) v.findViewById(R.id.emptyListText);

    mapUpdateHandler = new Handler();

    mapUpdater.run();

    return v;
}
项目:margarita    文件:LocationFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.location_fragment, container, false);
    // Gets the MapView from the XML layout and creates it
    mapView = (MapView) view.findViewById(R.id.map);
    mapView.onCreate(savedInstanceState);

    // Gets to GoogleMap from the MapView and does initialization stuff
    map = mapView.getMap();
    map.getUiSettings().setMyLocationButtonEnabled(false);
    map.setMyLocationEnabled(true);

    // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
    MapsInitializer.initialize(this.getActivity());
    map.setOnMarkerDragListener(this);

    mNetworkConnection = new NetworkConnection(getActivity());
    mLocationProvider = new LocationProvider(getActivity(), this);

    return view;
}
项目:BookMySkills    文件:MyHomeFragment.java   
private void initializeMap() throws GooglePlayServicesNotAvailableException {
    try {
        MapsInitializer.initialize(getActivity());
        if (getActivity().getSupportFragmentManager().findFragmentById(
                R.id.mapContainer) == null) {
            mapSupportFragment = MySupportMapFragment
                    .newInstatnce(new Bundle());
            mapSupportFragment.setTargetFragment(this, 100);
            if (getArguments() != null)
                mapSupportFragment.setArguments(getArguments());

            getActivity().getSupportFragmentManager().beginTransaction()
                    .add(R.id.mapContainer, mapSupportFragment).commit();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:investickation    文件:GoogleMapController.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mGoogleMap = googleMap;
    if (mGoogleMap != null) {
        // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
        try {
            initializeGoogleMap();
            MapsInitializer.initialize(mContext);
        } catch (Exception e) {
            e.printStackTrace();
        }
        mGoogleMap.setOnMyLocationChangeListener(myLocationChangeListener);
    } else {
        Log.i(TAG, "MapView is NULL");
    }

}
项目:SwipeableCard    文件:SwipeableCard.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mGoogleMap = googleMap;
    MapsInitializer.initialize(getContext());
    googleMap.getUiSettings().setMapToolbarEnabled(true);
    if (mMapLocation != null && !mOptionView.isMultipleMarker() && mOptionView.isSingleMarker()) {
        updateMapContents();
    }
    if(mOptionView.getLatLngArray() != null && mOptionView.getLatLngArray().length > 0 && mOptionView.isMultipleMarker() && !mOptionView.isSingleMarker())
    {
        updateMapContents();
    }
    if(mOptionView.getLatLngList() != null && mOptionView.getLatLngList().size() > 0 && mOptionView.isMultipleMarker() && !mOptionView.isSingleMarker())
    {
        updateMapContents();
    }
}
项目:TripWeather    文件:MapFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    MapsInitializer.initialize(getActivity()); // required for the CameraUpdateFactory to be initialized
    googleMap.clear();
    googleMap.setMyLocationEnabled(true);

    googleMap.addMarker(new MarkerOptions().position(fromLocation).title(fromTitle));
    googleMap.addMarker(new MarkerOptions().position(toLocation).title(toTitle));

    List<LatLng> route = PolyUtil.decode(encodedRoute);
    googleMap.addPolyline(new PolylineOptions().addAll(route).color(R.color.green));

    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(fromLocation)
            .include(toLocation)
            .build();
    googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}
项目:CheDream    文件:ContactsFragment.java   
private void setMap() {
    MapsInitializer.initialize(getActivity().getApplicationContext());

    GoogleMap googleMap = mMapView.getMap();

    LatLng latLng = new LatLng(49.426863, 32.095314);
    MarkerOptions marker = new MarkerOptions().position(latLng);

    marker.icon(BitmapDescriptorFactory
            .defaultMarker(BitmapDescriptorFactory.HUE_ROSE));

    googleMap.addMarker(marker);
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(latLng).zoom(12).build();
    googleMap.animateCamera(CameraUpdateFactory
            .newCameraPosition(cameraPosition));
}
项目:QuietPlaces    文件:QPMapFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_map, container, false);
    if (rootView == null) {
        Log.e(TAG, "rootView is null in onCreateView in QPMapFragment");
        return null;
    }

    MapsInitializer.initialize(getMyActivity());

    mMapView = (MapView) rootView.findViewById(R.id.map);
    if (mMapView != null) {
        mMapView.onCreate(mBundle);
        setUpMapIfNeeded(rootView);
    }

    MainActivity mainActivity = (MainActivity) getActivity();

    CheckBox followingUserCB = (CheckBox) rootView.findViewById(R.id.follow_user_checkBox);
    followingUserCB.setChecked(mainActivity.isFollowingUser());

    return rootView;
}
项目:commcare-android    文件:GeoPointMapActivity.java   
@Override
public void onMapReady(GoogleMap map) {
    this.map = map;

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED ||
            ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        map.getUiSettings().setMyLocationButtonEnabled(true);
        map.setMyLocationEnabled(true);
        map.setOnMyLocationButtonClickListener(this);
    }

    MapsInitializer.initialize(this);

    if (inViewMode) {
        drawMarker();
    }
    setupMapListeners();
}
项目:GeoQuake    文件:QuakeMapFragment.java   
public void moveCameraToUserLocation(double latitude, double longitude) {
    LatLng latLng = new LatLng(latitude, longitude);
    if (mMap == null) {
        return;
    }
    try {
        MapsInitializer.initialize(getActivity());
    } catch (Exception e) {
        Log.i(TAG, "Problem initializing map");
        return;
    }
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 4);
    mMap.animateCamera(cameraUpdate);
    mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude))
            .title(getActivity().getString(R.string.menu_my_location)));
}
项目:WMB    文件:RouteMapFragment.java   
@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Bundle args = getArguments();

    setUpBundleArgs(args);

    View v = inflater.inflate(R.layout.fragment_route_map, container, false);

    if (v != null) {
        mapView = (MapView) v.findViewById(R.id.map);
        if (mapView != null) {
            mapView.onCreate(savedInstanceState);
        }
    }

    MapsInitializer.initialize(this.getActivity());

    route = getRoute();

    setupMapIfNeeded(fromStop);

    return v;
}
项目:TruckMuncher-Android    文件:CustomerMapFragment.java   
@Override
public void onConnected(Bundle bundle) {
    Location myLocation = LocationServices.FusedLocationApi.getLastLocation(apiClient);
    if (myLocation != null) {
        LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
        MapsInitializer.initialize(getActivity());
        mapView.getMap().animateCamera(CameraUpdateFactory.newLatLng(latLng));
    }

    LocationRequest request = new LocationRequest()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setFastestInterval(FASTEST_REFRESH_INTERVAL)
            .setInterval(REFRESH_INTERVAL);
    LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, request, this);
    Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(apiClient);

    if (lastLocation != null) {
        onLocationChanged(lastLocation);
    }
}
项目:TruckMuncher-Android    文件:VendorMapFragment.java   
@Override
public void onConnected(Bundle bundle) {
    if (!useMapLocation) {
        Location myLocation = LocationServices.FusedLocationApi.getLastLocation(apiClient);
        if (myLocation != null) {
            LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
            MapsInitializer.initialize(getActivity());
            mapView.getMap().animateCamera(CameraUpdateFactory.newLatLng(latLng));
            onLocationUpdate(myLocation);
        }
    }

    request = new LocationRequest()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setFastestInterval(FASTEST_REFRESH_INTERVAL)
            .setInterval(REFRESH_INTERVAL);
    LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, request, this);
}
项目:PalHunterClient    文件:HomeFragment.java   
@Override
public View onCreateView(LayoutInflater inflater,
    @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  if (view != null) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null)
      parent.removeView(view);

  }
  view = inflater.inflate(R.layout.home_frg, container, false);
  mMapView = (MapView) view.findViewById(R.id.mapView);
  mMapView.onCreate(savedInstanceState);
  mMapView.onResume();

  try {
    MapsInitializer.initialize(context.getApplicationContext());
  } catch (Exception e) {
    e.printStackTrace();
  }
  initViews(view);
  return view;
}
项目:ceeq    文件:SecurityFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setActionBar();
    View view = inflater.inflate(R.layout.fragment_security, container, false);

    autoBlip = (ToggleButton) view.findViewById(R.id.toggle_blip);
    autoLocate = (ToggleButton) view.findViewById(R.id.toggle_locate);
    wipe = (Button) view.findViewById(R.id.wipe);
    wipeCache = (Button) view.findViewById(R.id.wipe_cache);

    mapView = (MapView) view.findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);
    mapView.onResume();
    try {
        MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
        e.printStackTrace();
    }
    map = mapView.getMap();
    setupMap();

    setupListeners();
    return view;
}
项目:Purdue-App-Old    文件:MapActivity.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Log event
    Log.d(LOG_MAP_TAG, "MapActivity : onCreate() called.");

    // Set the content view with a google map fragment
    setContentView(R.layout.map_activity_main);

    // Create the fragments for the UI
    MapActivityEventListener eventListener = new MapActivityEventListener(this);
    gmapFragment = ((GoogleMapFragment) getFragmentManager().findFragmentById(R.id.map_fragment_googlemapfragment));
    gmapFragment.setGMapFragmentLoadedListener(eventListener);
    buildingFragment = new BuildingListDialog();
    buildingFragment.setOnBuildingSelectedListener(eventListener);

    // Prepare MapData
    mpd = new MapData(this);

    // Initialize the gms maps services
    try {
        MapsInitializer.initialize(this);
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
}
项目:TFG-SmartU-La-red-social    文件:FragmentMapaProyecto.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    //Inicializo el mapa
    MapsInitializer.initialize(getContext());
    mMap = googleMap;

    //Si tengo proyectos los muestro en el mapa
    if (proyecto.getCoordenadas().compareTo("") != 0) {
        String[] coordenadas = proyecto.getCoordenadas().split(",");
        double lat = Double.parseDouble(coordenadas[0]);
        double lon = Double.parseDouble(coordenadas[1]);
        posicionProyecto = new LatLng(lat, lon);
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.title(proyecto.getNombre());
        //Pongo la descripción en el infowindow solo con 10 caracteres
        if (proyecto.getDescripcion().length() > 50)
            markerOptions.snippet(proyecto.getDescripcion().substring(0, 50));
        else
            markerOptions.snippet(proyecto.getDescripcion());
        markerOptions.position(posicionProyecto);
        mMap.addMarker(markerOptions);
    }

    // Movemos la camara a la posicion del usuario
    if (miPosicion != null)
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(miPosicion, 3));

}
项目:ExtraMapUtils    文件:ListViewFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    MapsInitializer.initialize(context);
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_night);
    map = googleMap;
    map.setMapStyle(style);
    final ViewOption viewOption = (ViewOption) mapView.getTag();
    if (viewOption != null) {
        setMapLocation(viewOption, map, context);
    }
}
项目:MADBike    文件:StationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AnalyticsManager.getInstance().trackContentView("StationScreen");
    MapsInitializer.initialize(this);
    initManagers();
    initMap(savedInstanceState);
}
项目:MADBike    文件:FavoriteActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(CommonStatusCodes.SUCCESS);
    MapsInitializer.initialize(this);
    gson = new Gson();
    if (getIntent().getExtras().getString(FavoritesFragment.DATA) != null) {
        station = gson.fromJson(getIntent().getExtras().getString(FavoritesFragment.DATA), Station.class);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(station.getNombre());
        }
        nameTextView.setText(station.getNumberStation() + " " + station.getNombre());
        streetTextView.setText(station.getAddress());

        totalTextView.setText(getString(R.string.bases) + "\n" + station.getNumberBases());
        freeTextView.setText(getString(R.string.bases_free) + "\n" + station.getBasesFree());
        engagedTextView.setText(getString(R.string.bases_engaged) + "\n" + station.getBikeEngaged());

        favoriteItems = gson.fromJson(Preferences.getInstance(this).getIdFav(), FavoriteItem[].class);
        if (favoriteItems != null) {
            for (int i = 0; i < favoriteItems.length; i++) {
                FavoriteItem f = favoriteItems[i];
                if (f.getId().equalsIgnoreCase(station.getIdStation())) {
                    fab.setImageResource(R.drawable.ic_favorite);
                    isFavorite = true;
                    break;
                } else {
                    fab.setImageResource(R.drawable.ic_favorite_empty);
                    isFavorite = true;
                }
            }
        }

        initMap(savedInstanceState);
    } else {
        finish();
    }

}
项目:youth-health    文件:MapFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_map, container, false);

    mMapView = (MapView) rootView.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();
    }

    mMapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap mMap) {
            googleMap = mMap;

            // For dropping a marker at a point on the Map
            LatLng sydney = new LatLng(-34, 151);
            googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").snippet("Marker Description"));

            // For zooming automatically to the location of the marker
            CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build();
            googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        }
    });

    return rootView;
}
项目:Remindy    文件:EditLocationBasedReminderFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {

    mMap = googleMap;

    MapsInitializer.initialize(getActivity().getApplicationContext());
    mMap.getUiSettings().setMapToolbarEnabled(false);
    mMap.getUiSettings().setAllGesturesEnabled(false);

    updateMapView();
}
项目:Remindy    文件:PlaceViewHolder.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    MapsInitializer.initialize(mActivity.getApplicationContext());
    mMap.getUiSettings().setMapToolbarEnabled(false);
    mMap.getUiSettings().setAllGesturesEnabled(false);

    updateMapView();
}
项目:oma-riista-android    文件:EntryMapView.java   
public void setup(Context context, boolean showGpsLevel, boolean showAccuracy, AppPreferences.MapTileSource tileType) {
    mShowInfoWindow = showGpsLevel;
    mShowAccuracy = showAccuracy;
    mTiletype = tileType;

    getMapAsync(this);
    MapsInitializer.initialize(context);

    mMyInfoWindowAdapter = new MyInfoWindowAdapter(context);
}
项目:bikedeboa-android    文件:DetailActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {

    MapsInitializer.initialize(this);
    customizeMap(googleMap);
    detailViewModel.setUpMap(googleMap);
}
项目:techstar-org    文件:MapFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_map, container, false);

    mMapView = (MapView) rootView.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();
    }

    mMapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap mMap) {
            googleMap = mMap;

            // For dropping a marker at a point on the Map
            LatLng sydney = new LatLng(-34, 151);
            googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").snippet("Marker Description"));

            // For zooming automatically to the location of the marker
            CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build();
            googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        }
    });

    return rootView;
}
项目:narrate-android    文件:PlaceOnAMapDialog.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getIntent().getExtras();
    this.title = args.getString("title", null);
    this.location = args.getParcelable("location");

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    setContentView(R.layout.dialog_place_on_a_map);

    TextView textViewTitle = (TextView) findViewById(R.id.dialog_title);
    if (this.title != null)
        textViewTitle.setText(this.title);
    else
        textViewTitle.setText(location.latitude + ", " + location.longitude);

    try {
        MapsInitializer.initialize(this);
    } catch (Exception e) {
        e.printStackTrace();
    }

    map = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    map.getUiSettings().setScrollGesturesEnabled(false);
    map.getUiSettings().setZoomGesturesEnabled(false);
    map.getUiSettings().setRotateGesturesEnabled(false);

    map.addMarker(new MarkerOptions()
            .position(location));

    CameraPosition newPosition = CameraPosition.fromLatLngZoom(location, 12.0f);
    map.moveCamera(CameraUpdateFactory.newCameraPosition(newPosition));
}
项目:narrate-android    文件:LocationPickerDialog.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.location_picker_dialog);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    try {
        MapsInitializer.initialize(this);
    } catch (Exception e) {
        e.printStackTrace();
    }

    mMap = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    mMap.setMyLocationEnabled(true);

    if ( getIntent().getParcelableExtra("location") != null ) {
        final CameraPosition newPosition = CameraPosition.fromLatLngZoom((LatLng) getIntent().getParcelableExtra("location"), 15);

        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(newPosition));
            }
        }, 500);
    }

    findViewById(R.id.save).setOnClickListener(this);
    findViewById(R.id.cancel).setOnClickListener(this);
}
项目:event-app    文件:LocationMapFragment.java   
private void buildMap(View v, Bundle savedInstanceState) {
    mMapView = (MapView) v.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);
    mMapView.onResume();

    try {
        MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
        e.printStackTrace();
    }

    mMapView.getMapAsync(this);
}
项目:memoir    文件:AtlasFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_atlas, container, false);

    MapsInitializer.initialize(getActivity());
    mMapView = (MapView) v.findViewById(R.id.map_view);
    mMapView.onCreate(mBundle);
    mMapView.getMapAsync(this);

    return v;
}
项目:Gourmet    文件:RestaurantsMapActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_restaurants_map);
    ButterKnife.bind(this);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);

    MapsInitializer.initialize(getApplicationContext());

    mapFragment.getMapAsync(this);
}
项目:Airbnb-Android-Google-Map-View    文件:RecyclerViewLiteModeAdapter.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    MapsInitializer.initialize(mContext);
    map = googleMap;
    isMapReady=true;
    map.getUiSettings().setMapToolbarEnabled(false);

    if (mapView.getViewTreeObserver().isAlive()) {
        mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @SuppressWarnings("deprecation") // We use the new method when supported
            @SuppressLint("NewApi") // We check which build version we are using.
            @Override
            public void onGlobalLayout() {
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                    mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                } else {
                    mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
                //  showBoth(null);
            }
        });
    }
    try{
        setMapData(new LatLng(Double.parseDouble(addressModel.getLatitude()),Double.parseDouble(addressModel.getLongitude())));
    }catch(Exception e){
        e.printStackTrace();
    }


    //  mapInterface.mapIsReadyToSet(this,position);
}
项目:mConference-Framework    文件:Venue.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_venue, container,
            false);
    MapsInitializer.initialize(getActivity().getApplicationContext());
    scrollView = (ScrollView) v.findViewById(R.id.venue_scrollview);
    mMapView = (VenueMapView) v.findViewById(R.id.mapView);
    TextView address = (TextView) v.findViewById(R.id.venue_detail);

    sharedPref = getActivity().getApplicationContext()
            .getSharedPreferences(PREFERENCES_FILE_NAME, Context.MODE_PRIVATE);
    venueAddress = sharedPref.getString(VENUE_TAG, null);
    address.setText(venueAddress);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume();// needed to get the map to display immediately

    status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());

    googleMap = mMapView.getMap();

    new MapPlotting().execute();

    return v;
}