public Builder<T> iconId(int iconId) { try { markerOptions.icon(BitmapDescriptorFactory.fromResource(iconId)); } catch (NullPointerException ignored) { // google play services is not available } return this; }
private Cap getSelectedCap(int pos) { switch (CAP_TYPE_NAME_RESOURCE_IDS[pos]) { case R.string.cap_butt: return new ButtCap(); case R.string.cap_square: return new SquareCap(); case R.string.cap_round: return new RoundCap(); case R.string.cap_image: return new CustomCap( BitmapDescriptorFactory.fromResource(R.drawable.chevron), CUSTOM_CAP_IMAGE_REF_WIDTH_PX); } return null; }
@Override public void onMapReady(GoogleMap map) { // Register a listener to respond to clicks on GroundOverlays. map.setOnGroundOverlayClickListener(this); map.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11)); mImages.clear(); mImages.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)); mImages.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_prudential_sunny)); // Add a small, rotated overlay that is clickable by default // (set by the initial state of the checkbox.) mGroundOverlayRotated = map.addGroundOverlay(new GroundOverlayOptions() .image(mImages.get(1)).anchor(0, 1) .position(NEAR_NEWARK, 4300f, 3025f) .bearing(30) .clickable(((CheckBox) findViewById(R.id.toggleClickability)).isChecked())); // Add a large overlay at Newark on top of the smaller overlay. mGroundOverlay = map.addGroundOverlay(new GroundOverlayOptions() .image(mImages.get(mCurrentEntry)).anchor(0, 1) .position(NEWARK, 8600f, 6500f)); mTransparencyBar.setOnSeekBarChangeListener(this); // Override the default content description on the view, for accessibility mode. // Ideally this string would be localised. map.setContentDescription("Google Map with ground overlay."); }
@Override public void onMapReady(GoogleMap map) { map.setOnMarkerDragListener(SplitStreetViewPanoramaAndMapDemoActivity.this); // Creates a draggable marker. Long press to drag. mMarker = map.addMarker(new MarkerOptions() .position(markerPosition) .icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman)) .draggable(true)); } });
.image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge)) .position(SYDNEY, 700000) .clickable(true));
@Override public BitmapDescriptor fromResource(@DrawableRes int resourceId) { return new BitmapDescriptorAdapter( com.google.android.gms.maps.model.BitmapDescriptorFactory.fromResource(resourceId) ); }
.title("Sydney") .snippet("Population: 4,627,300") .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)) .infoWindowAnchor(0.5f, 0.5f));
protected Marker addMarker(LatLng latLng, @DrawableRes int markerPinRes) { return mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(markerPinRes)).draggable(true)); }
@Override public void onMapLongClick(LatLng latLng) { mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.avion)) .anchor(0.0f, 1.0f) .position(latLng)); } });
private void drawUserPositionMarker(Location location){ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); if(this.userPositionMarkerBitmapDescriptor == null){ userPositionMarkerBitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.user_position_point); } if (userPositionMarker == null) { userPositionMarker = map.addMarker(new MarkerOptions() .position(latLng) .flat(true) .anchor(0.5f, 0.5f) .icon(this.userPositionMarkerBitmapDescriptor)); } else { userPositionMarker.setPosition(latLng); } }
@Override public void onMapClick(LatLng latLng) { map.clear(); map.addMarker(new MarkerOptions() .position(new LatLng(latLng.latitude, latLng.longitude)) .title("Starting Point") .icon(BitmapDescriptorFactory.fromResource(R.drawable.antar)) ); myLatLng=latLng; } @Override
public void createAllMarkersInvisible() { LatLng northPoleHideout = new LatLng(90.0D, 0.0D); destMarker = map.addMarker(new MarkerOptions().position(northPoleHideout).icon(BitmapDescriptorFactory.fromBitmap(drawableDest))); destMarker.setVisible(false); currentPosition = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_ohne)).anchor(0.5f, 0.5f)); currentPosition.setVisible(false); current_position_anim_ohne = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_anim_ohne)).anchor(0.5f, 0.5f)); current_position_anim_ohne.setVisible(false); }
/** * 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 onMapClick(LatLng latLng) { map.clear(); map.addMarker(new MarkerOptions() .position(new LatLng(latLng.latitude, latLng.longitude)) .title("Starting Point") .icon(BitmapDescriptorFactory.fromResource(R.drawable.antar)) ); myLatLng=latLng; } @Override
protected Marker addMarker(LatLng latLng) { if (getMarkerIconRes() != 0) return mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(getMarkerIconRes())).draggable(true)); else return mMap.addMarker(new MarkerOptions().position(latLng).draggable(true)); }
/** * Triggered when the map is ready to be used. * * @param googleMap The GoogleMap object representing the Google Map. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Pan the camera to your home address (in this case, Google HQ). LatLng home = new LatLng(37.421982, -122.085109); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home, INITIAL_ZOOM)); // Add a ground overlay 100 meters in width to the home location. GroundOverlayOptions homeOverlay = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.android)) .position(home, 100); mMap.addGroundOverlay(homeOverlay); setMapLongClick(mMap); // Set a long click listener for the map; setPoiClick(mMap); // Set a click listener for points of interest. setMapStyle(mMap); // Set the custom map style. enableMyLocation(mMap); // Enable location tracking. // Enable going into StreetView by clicking on an InfoWindow from a // point of interest. setInfoWindowClickToPanorama(mMap); }
.icon(BitmapDescriptorFactory.fromResource(R.drawable.imagecover_flag)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(sydney));
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.car_small);
private void showLocationCircle(LatLng center, double accuracyRadius) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(0x201681FB) .strokeColor(0x500A78DD) .zIndex(1.0f) .visible(true) .strokeWidth(5.0f)); mHeadingMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .flat(true)); } } else { // move existing markers position to received location mCircle.setCenter(center); mHeadingMarker.setPosition(center); mCircle.setRadius(accuracyRadius); } }
private void showBlueDot(LatLng center, double accuracyRadius, double bearing) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(0x201681FB) .strokeColor(0x500A78DD) .zIndex(1.0f) .visible(true) .strokeWidth(5.0f)); mMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .rotation((float)bearing) .flat(true)); } } else { // move existing markers position to received location mCircle.setCenter(center); mCircle.setRadius(accuracyRadius); mMarker.setPosition(center); mMarker.setRotation((float)bearing); } }
private void showBlueDot(LatLng center, double accuracyRadius, double bearing) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(ACTIVE_LEVEL_BLUE_DOT_COLOR) .strokeColor(0x00000000) .zIndex(1.0f) .visible(true)); mMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .rotation((float)bearing) .flat(true)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(center, 17.0f)); } } else { mCircle.setCenter(center); mCircle.setRadius(accuracyRadius); mMarker.setPosition(center); mMarker.setRotation((float)bearing); } }