com.google.android.gms.maps.CameraUpdateFactory Java Examples

The following examples show how to use com.google.android.gms.maps.CameraUpdateFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CacheDetailActivity.java    From Forage with Mozilla Public License 2.0 8 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    googleMap.getUiSettings().setMapToolbarEnabled(false);

    // Add marker for geocache and move camera
    LatLng markerPos = new LatLng(location.getLatitude(), location.getLongitude());
    googleMap.addMarker(new MarkerOptions()
            .position(markerPos));

    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(markerPos)
            .zoom(13).build();

    googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

}
 
Example #2
Source File: GglMap.java    From FimiX8-RE with MIT License 7 votes vote down vote up
public void onMapReady(GoogleMap googleMap) {
    this.googleMap = googleMap;
    this.noFlyZone = new GglMapNoFlyZone(googleMap);
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(this.BEIJING, 9.49f));
    if (ContextCompat.checkSelfPermission(this.context, "android.permission.ACCESS_FINE_LOCATION") == 0 || ContextCompat.checkSelfPermission(this.context, "android.permission.ACCESS_COARSE_LOCATION") == 0) {
        googleMap.setMyLocationEnabled(false);
        googleMap.getUiSettings().setMyLocationButtonEnabled(false);
        googleMap.getUiSettings().setCompassEnabled(false);
        googleMap.getUiSettings().setMapToolbarEnabled(false);
        googleMap.getUiSettings().setRotateGesturesEnabled(false);
        this.gglMapLocationManager = new GglMapLocationManager(googleMap, this.context);
        this.aiP2PManager = new GglMapAiPoint2PointManager(this.context, googleMap, this.gglMapLocationManager);
        this.aiSurroundManager = new GglMapAiSurroundManager(this.context, googleMap, this.gglMapLocationManager);
        this.aiLineManager = new GglMapAiLineManager(this.context, googleMap, this.gglMapLocationManager);
        this.gglMapLocationManager.onStart();
        this.isInit = true;
        if (GlobalConfig.getInstance().getMapStyle() == Constants.X8_GENERAL_MAP_STYLE_NORMAL) {
            googleMap.setMapType(1);
        } else if (GlobalConfig.getInstance().getMapStyle() == Constants.X8_GENERAL_MAP_STYLE_SATELLITE) {
            googleMap.setMapType(2);
        }
    }
}
 
Example #3
Source File: MainActivity.java    From TutosAndroidFrance with MIT License 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {

            googleMap.addMarker(new MarkerOptions().title("Paris").position(PARIS));

            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(PARIS, 15));
            googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

        }
    });
}
 
Example #4
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
private void implementPickupRecyclerView(final ArrayList<Results> results) {
    PlacesAdapter placesAdapter=new PlacesAdapter(this, results, new ClickListener() {
        @Override
        public void onClick(View view, int index) {
            mPlaceLocation=results.get(index).formatted_address;
            etFinalPickup.setText(mPlaceLocation);

            llPickupInput.setVisibility(View.GONE);
            llPickupPlace.setVisibility(View.VISIBLE);
            llDestinationInput.setVisibility(View.GONE);
            llDestinationPlace.setVisibility(View.VISIBLE);

            Double lat=Double.valueOf(results.get(index).geometry.location.lat);
            Double lng=Double.valueOf(results.get(index).geometry.location.lng);
            LatLng latLng=new LatLng(lat, lng);
            if(riderMarket!=null)
                riderMarket.remove();
            riderMarket=mMap.addMarker(new MarkerOptions().position(latLng)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marker))
                    .title("Pickup Here"));
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15.0f));
        }
    });
    rvPickupPlaces.setAdapter(placesAdapter);
}
 
Example #5
Source File: Venue.java    From mConference-Framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    if (status == ConnectionResult.SUCCESS) {
        // create marker
        MarkerOptions marker = new MarkerOptions().position(
                new LatLng(latitude, longitude)).title(venueAddress);

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

        // adding marker
        googleMap.addMarker(marker);
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(latitude, longitude)).zoom(12).build();
        googleMap.animateCamera(CameraUpdateFactory
                .newCameraPosition(cameraPosition));
    } else {
        DialogFragment dialogFragment = new PlayServicesUnavailableDialogFragment();
        dialogFragment.show(getActivity().getFragmentManager(), "Play Service Problem");
    }
}
 
Example #6
Source File: CustomMarkerClusteringDemoActivity.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
@Override
protected void startDemo(boolean isRestore) {
    if (!isRestore) {
        getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 9.5f));
    }

    mClusterManager = new ClusterManager<>(this, getMap());
    mClusterManager.setRenderer(new PersonRenderer());
    getMap().setOnCameraIdleListener(mClusterManager);
    getMap().setOnMarkerClickListener(mClusterManager);
    getMap().setOnInfoWindowClickListener(mClusterManager);
    mClusterManager.setOnClusterClickListener(this);
    mClusterManager.setOnClusterInfoWindowClickListener(this);
    mClusterManager.setOnClusterItemClickListener(this);
    mClusterManager.setOnClusterItemInfoWindowClickListener(this);

    addItems();
    mClusterManager.cluster();
}
 
Example #7
Source File: MainActivity.java    From roads-api-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(List<SnappedPoint> snappedPoints) {
    mSnappedPoints = snappedPoints;
    mProgressBar.setVisibility(View.INVISIBLE);

    findViewById(R.id.speed_limits).setEnabled(true);

    com.google.android.gms.maps.model.LatLng[] mapPoints =
            new com.google.android.gms.maps.model.LatLng[mSnappedPoints.size()];
    int i = 0;
    LatLngBounds.Builder bounds = new LatLngBounds.Builder();
    for (SnappedPoint point : mSnappedPoints) {
        mapPoints[i] = new com.google.android.gms.maps.model.LatLng(point.location.lat,
                point.location.lng);
        bounds.include(mapPoints[i]);
        i += 1;
    }

    mMap.addPolyline(new PolylineOptions().add(mapPoints).color(Color.BLUE));
    mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 0));
}
 
Example #8
Source File: NiboPickerFragment.java    From Nibo with MIT License 6 votes vote down vote up
protected void addSingleMarkerToMap(LatLng latLng) {
    if (mMap != null) {
        if (mCurrentMapMarker != null) {
            mCurrentMapMarker.remove();
        }
        CameraPosition cameraPosition =
                new CameraPosition.Builder().target(latLng)
                        .zoom(getDefaultZoom())
                        .build();
        hasWiderZoom = false;
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        mCurrentMapMarker = addMarker(latLng);
        mMap.setOnMarkerDragListener(this);
        extractGeocode(latLng.latitude, latLng.longitude);
    }
}
 
Example #9
Source File: MosquesActivity.java    From MuslimMateAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
    if (location.getLatitude() != 0 || location.getLongitude() != 0) {
        setFusedLatitude(location.getLatitude());
        setFusedLongitude(location.getLongitude());
        stopFusedLocation();
        CameraPosition oldPos = googleMap.getCameraPosition();
        CameraPosition pos = CameraPosition.builder(oldPos)
                .target(getPosition())
                .zoom(zoom)
                .build();
        googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos));

        Marker marker = googleMap.addMarker(new MarkerOptions()
                .position(getPosition())
                .title("My Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.placeholder)));


        AsyncTask placesAsync = new Places().execute(getPosition());

    }

}
 
Example #10
Source File: Mapa.java    From android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Añade la marca de una gasolinera
    * @param gasolinera
 */
private void marcarGasolinera(Gasolinera gasolinera) {
	
	// Prepara y añade una nueva marca al mapa
	mapa.addMarker(new MarkerOptions()
		.position(gasolinera.getPosicion())
		.title(gasolinera.getNombre()));
	
	// Posiciona la vista del usuario en el punto que se acaba de agregar
   	CameraUpdate camara =
   			CameraUpdateFactory.newLatLng(gasolinera.getPosicion());
       	 
   	// Coloca la vista del mapa sobre la posición de la gasolinera 
   	// y activa el zoom para verlo de cerca
   	mapa.moveCamera(camara);
   	mapa.animateCamera(CameraUpdateFactory.zoomTo(12.0f), 2000, null);
}
 
Example #11
Source File: Map.java    From MapsMeasure with Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {
        metric = savedInstanceState.getBoolean("metric");
        @SuppressWarnings("unchecked")
        // Casting to Stack<LatLng> apparently results in
                // "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack"
                // on some devices
                List<LatLng> tmp = (List<LatLng>) savedInstanceState.getSerializable("trace");
        Iterator<LatLng> it = tmp.iterator();
        while (it.hasNext()) {
            addPoint(it.next());
        }
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(savedInstanceState.getDouble("position-lat"),
                        savedInstanceState.getDouble("position-lon")),
                savedInstanceState.getFloat("position-zoom")));
    } catch (Exception e) {
        if (BuildConfig.DEBUG) Logger.log(e);
        e.printStackTrace();
    }
}
 
Example #12
Source File: PTRMapFragment.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
private void setInitialCameraPosition() {
	double lng, lat;
	float tilt, bearing, zoom;

	SharedPreferences settings = getActivity().getSharedPreferences( EXTRAS_SHARED_PREFERENCES, 0 );
	lng = Double.longBitsToDouble( settings.getLong( SAVED_STATE_LONG, Double.doubleToLongBits( mLocationClient.getLastLocation().getLongitude() ) ) );
	lat = Double.longBitsToDouble( settings.getLong( SAVED_STATE_LAT, Double.doubleToLongBits( mLocationClient.getLastLocation().getLatitude() ) ) );
	zoom = settings.getFloat( SAVED_STATE_ZOOM, 17 );
	bearing = settings.getFloat( SAVED_STATE_BEARING, 0 );
	tilt = settings.getFloat( SAVED_STATE_TILT, 30 );

	CameraPosition cameraPosition = new CameraPosition.Builder()
			.target( new LatLng( lat, lng) )
			.zoom( zoom )
			.bearing( bearing )
			.tilt( tilt )
			.build();
	if( cameraPosition == null || mMap == null )
		return;
	mMap.animateCamera( CameraUpdateFactory.newCameraPosition( cameraPosition ) );
}
 
Example #13
Source File: Home.java    From Taxi-App-Android-XML with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    LatLng southjakarta = new LatLng(-6.22865,106.8151753);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.addMarker(new MarkerOptions().position(southjakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Dropoff Location", R.drawable.dot_dropoff))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));


}
 
Example #14
Source File: LocationGeofenceEditorActivity.java    From PhoneProfilesPlus with Apache License 2.0 6 votes vote down vote up
private float getCircleZoomValue(double latitude, double longitude, double radius,
                               float minZoom, float maxZoom) {
    LatLng position = new LatLng(latitude, longitude);
    float currZoom = (minZoom + maxZoom) / 2;
    CameraUpdate camera = CameraUpdateFactory.newLatLngZoom(position, currZoom);
    mMap.moveCamera(camera);
    float[] results = new float[1];
    LatLng topLeft = mMap.getProjection().getVisibleRegion().farLeft;
    LatLng topRight = mMap.getProjection().getVisibleRegion().farRight;
    Location.distanceBetween(topLeft.latitude, topLeft.longitude, topRight.latitude,
                                topRight.longitude, results);
    // Difference between visible width in meters and 2.5 * radius.
    double delta = results[0] - 2.5 * radius;
    double accuracy = 10; // 10 meters.
    if (delta < -accuracy)
        return getCircleZoomValue(latitude, longitude, radius, minZoom, currZoom);
    else
    if (delta > accuracy)
        return getCircleZoomValue(latitude, longitude, radius, currZoom, maxZoom);
    else
        return currZoom;
}
 
Example #15
Source File: AddMapActivity.java    From JalanJalan with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onConnected(Bundle bundle) {
    if (location == null) {
        // get last location device
        location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
        if (mMap != null) {
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 13));
            mMap.addMarker(new MarkerOptions()
                            .position(new LatLng(location.getLatitude(), location.getLongitude()))
                            .title("Starting Point")
                            .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
            );
            lat = location.getLatitude();
            lng = location.getLongitude();

            Toast.makeText(this, "Lokasi kamu saat ini, sebagai patokan titik awal perjalanan kamu kak :')", Toast.LENGTH_LONG).show();
        }
    }

}
 
Example #16
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {

  googleMap.addMarker(new MarkerOptions()
          .position(new LatLng(37.4233438, -122.0728817))
          .title("LinkedIn")
          .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(37.4629101,-122.2449094))
            .title("Facebook")
            .snippet("Facebook HQ: Menlo Park"));

    googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(37.3092293, -122.1136845))
            .title("Apple"));

    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.4233438, -122.0728817), 10));

}
 
Example #17
Source File: ShareLocationActivity.java    From Track-My-Location with GNU General Public License v3.0 6 votes vote down vote up
private void onLocationUpdated(Location location) {
    String latlng = location.getLatitude() + "/" + location.getLongitude();
    mTextLatLng.setText(latlng);

    LatLng pos = new LatLng(location.getLatitude(), location.getLongitude());
    if (mGoogleMap == null) return;
    if (mMyLocMarker == null) {
        MarkerOptions options = new MarkerOptions().title("Me").position(pos);
        mMyLocMarker = mGoogleMap.addMarker(options);
        mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, DEFAULT_ZOOM_LEVEL));
    } else {
        mMyLocMarker.setPosition(pos);
        if (mFollowMarker) {
            mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(pos));
        } else if (!isLatLngOnVisibleRegion(pos)) {
            mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(pos));
        }
    }
}
 
Example #18
Source File: CustomMarkerClusteringDemoActivity.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onClusterClick(Cluster<Person> cluster) {
    // Show a toast with some info when the cluster is clicked.
    String firstName = cluster.getItems().iterator().next().name;
    Toast.makeText(this, cluster.getSize() + " (including " + firstName + ")", Toast.LENGTH_SHORT).show();

    // Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
    // inside of bounds, then animate to center of the bounds.

    // Create the builder to collect all essential cluster items for the bounds.
    LatLngBounds.Builder builder = LatLngBounds.builder();
    for (ClusterItem item : cluster.getItems()) {
        builder.include(item.getPosition());
    }
    // Get the LatLngBounds
    final LatLngBounds bounds = builder.build();

    // Animate camera to the bounds
    try {
        getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
    } catch (Exception e) {
        e.printStackTrace();
    }

    return true;
}
 
Example #19
Source File: Android_Mapas.java    From android with GNU General Public License v2.0 6 votes vote down vote up
private void localizarGasolinera() {
	
	if (spGasolineras.getSelectedItemPosition() == Spinner.INVALID_POSITION) {
		return;
	}
	
	Gasolinera gasolinera = listaGasolineras.get(spGasolineras.getSelectedItemPosition());
	
	// Prepara y añade una nueva marca al mapa
	mapa.addMarker(new MarkerOptions()
		.position(gasolinera.getPosicion())
		.title(gasolinera.getNombre()));
	
	// Posiciona la vista del usuario en el punto que se acaba de agregar
   	CameraUpdate camara =
   			CameraUpdateFactory.newLatLng(gasolinera.getPosicion());
       	 
   	// Coloca la vista del mapa sobre la posición del restaurante
   	// y activa el zoom para verlo de cerca
   	mapa.moveCamera(camara);
   	mapa.animateCamera(CameraUpdateFactory.zoomTo(12.0f)); 
}
 
Example #20
Source File: NiboOriginDestinationPickerFragment.java    From Nibo with MIT License 6 votes vote down vote up
void addOriginMarker(LatLng latLng) {
    if (mMap != null) {
        if (mOriginMapMarker != null) {
            mOriginMapMarker.remove();
            mOriginMapMarker = null;
        }
        CameraPosition cameraPosition =
                new CameraPosition.Builder().target(latLng)
                        .zoom(getDefaultZoom())
                        .build();

        hasWiderZoom = false;
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

        if (mOriginMarkerPinIconRes != DEFAULT_MARKER_ICON_RES) {
            mOriginMapMarker = addMarker(latLng, mOriginMarkerPinIconRes);
        } else {
            mOriginMapMarker = addMarker(latLng);
        }


        mMap.setOnMarkerDragListener(this);

        showBothMarkersAndGetDirections();
    }
}
 
Example #21
Source File: AttractionsGridPagerAdapter.java    From io2015-codelabs with Apache License 2.0 5 votes vote down vote up
private void updateMapLocation(Attraction attraction) {
    mMap.clear();
    mMap.moveCamera(
            CameraUpdateFactory.newLatLng(attraction.location));
    mMap.addMarker(new MarkerOptions()
            .position(attraction.location)
            .title(attraction.name));
}
 
Example #22
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }


    //MyItem current location marker
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    latitud = location.getLatitude();
    longitud = location.getLongitude();


    CameraPosition PosicionCamara = CameraPosition.builder()
            .target(latLng)//Direccion de la camara
            .zoom(20)//Zoom al mapa
            .bearing(90)//Dirección que la cámara está apuntando en, en grados en sentido horario desde el norte.
            .build();


    mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(PosicionCamara),
            6000, null);
    //move map camera
    // mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(15));


    if (mGoogleApiClient != null) {
        LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
    }


}
 
Example #23
Source File: GeoJsonDemoActivity.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
@Override
protected void startDemo(boolean isRestore) {
    if (!isRestore) {
        getMap().moveCamera(CameraUpdateFactory.newLatLng(new LatLng(31.4118,-103.5355)));
    }
    // Download the GeoJSON file.
    retrieveFileFromUrl();
    // Alternate approach of loading a local GeoJSON file.
    //retrieveFileFromResource();
}
 
Example #24
Source File: Clusterkraf.java    From clusterkraf with Apache License 2.0 5 votes vote down vote up
/**
 * Animate the camera so all of the InputPoint objects represented by the
 * passed ClusterPoint are in view
 * 
 * @param clusterPoint
 */
public void zoomToBounds(ClusterPoint clusterPoint) {
	GoogleMap map = mapRef.get();
	if (map != null && clusterPoint != null) {
		innerCallbackListener.clusteringOnCameraChangeListener.setDirty(System.currentTimeMillis());
		CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(clusterPoint.getBoundsOfInputPoints(), options.getZoomToBoundsPadding());
		map.animateCamera(cameraUpdate, options.getZoomToBoundsAnimationDuration(), null);
	}
}
 
Example #25
Source File: MapPickerActivity.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onMyLocationChange(Location location) {

    if (currentLocation == null) {
        // do we need to attach our location on the start?
        this.currentLocation = location;
        fetchPlaces(null);
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 14));
    }
    this.currentLocation = location;
    accuranceView.setText(getString(R.string.picker_map_pick_my_accuracy, (int) currentLocation.getAccuracy()));
    Log.d("Location changed", location.toString());
}
 
Example #26
Source File: IconGeneratorDemoActivity.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
@Override
protected void startDemo(boolean isRestore) {
    if (!isRestore) {
        getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8696, 151.2094), 10));
    }

    IconGenerator iconFactory = new IconGenerator(this);
    addIcon(iconFactory, "Default", new LatLng(-33.8696, 151.2094));

    iconFactory.setColor(Color.CYAN);
    addIcon(iconFactory, "Custom color", new LatLng(-33.9360, 151.2070));

    iconFactory.setRotation(90);
    iconFactory.setStyle(IconGenerator.STYLE_RED);
    addIcon(iconFactory, "Rotated 90 degrees", new LatLng(-33.8858, 151.096));

    iconFactory.setContentRotation(-90);
    iconFactory.setStyle(IconGenerator.STYLE_PURPLE);
    addIcon(iconFactory, "Rotate=90, ContentRotate=-90", new LatLng(-33.9992, 151.098));

    iconFactory.setRotation(0);
    iconFactory.setContentRotation(90);
    iconFactory.setStyle(IconGenerator.STYLE_GREEN);
    addIcon(iconFactory, "ContentRotate=90", new LatLng(-33.7677, 151.244));

    iconFactory.setRotation(0);
    iconFactory.setContentRotation(0);
    iconFactory.setStyle(IconGenerator.STYLE_ORANGE);
    addIcon(iconFactory, makeCharSequence(), new LatLng(-33.77720, 151.12412));
}
 
Example #27
Source File: ShopLocationActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
/**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        // Add a marker in place and move the camera
//        Log.d("OnMapReady", "here");
//        Log.d("OnMapReady", "type:" + type);
        switch (type) {
            case "shopItem":
                LatLng shopLocation1 = new LatLng(shop.getLatitude(), shop.getLongitude());
                Marker shopLocationMarker1 = mMap.addMarker(new MarkerOptions().position(shopLocation1)
                        .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
                mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(shopLocation1, 15));
//        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(shopLocation, 17), 2000, null);
//                Log.d("OnMapReady", "shopItem");
                break;
            case "brandShops":
                for (int i = 0; i < brandShops.size(); i++) {
                    LatLng shopLocation2 = new LatLng(brandShops.get(i).getLatitude(), brandShops.get(i).getLongitude());
                    Marker shopLocationMarker2 = mMap.addMarker(new MarkerOptions().position(shopLocation2)
                            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
                    if (i == 0) {
                        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(shopLocation2, 10));
                    }
                }
//                Log.d("OnMapReady", "brandShop");
                break;
        }

    }
 
Example #28
Source File: MapsActivity.java    From Airbnb-Android-Google-Map-View with MIT License 5 votes vote down vote up
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
 
Example #29
Source File: GridAdapter.java    From snazzymaps-browser with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the map for each grid item by showing it, applying the given style, and
 * setting up the click handler.
 *
 * @param map
 * @param style
 */
private void initializeMap(GoogleMap map, final SnazzyMapsStyle style) {
    style.applyToMap(map);
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(MapActivity.START_LATLNG, 10));
    map.getUiSettings().setMapToolbarEnabled(false);  // Removes the map button.
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);  // Shows the map.
    map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            ((OnGridItemClickHandler) mContext).onGridItemClick(style);
        }
    });
}
 
Example #30
Source File: SignalMapView.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public ListenableFuture<Bitmap> display(final SignalPlace place) {
  final SettableFuture<Bitmap> future = new SettableFuture<>();

  this.mapView.onCreate(null);
  this.mapView.onResume();

  this.mapView.setVisibility(View.VISIBLE);
  this.imageView.setVisibility(View.GONE);

  this.mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(final GoogleMap googleMap) {
      googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLong(), 13));
      googleMap.addMarker(new MarkerOptions().position(place.getLatLong()));
      googleMap.setBuildingsEnabled(true);
      googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      googleMap.getUiSettings().setAllGesturesEnabled(false);
      googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
          googleMap.snapshot(new GoogleMap.SnapshotReadyCallback() {
            @Override
            public void onSnapshotReady(Bitmap bitmap) {
              future.set(bitmap);
              imageView.setImageBitmap(bitmap);
              imageView.setVisibility(View.VISIBLE);
              mapView.setVisibility(View.GONE);
              mapView.onPause();
              mapView.onDestroy();
            }
          });
        }
      });
    }
  });

  this.textView.setText(place.getDescription());

  return future;
}