private void addMarker(GoogleMap map, double lat, double lon, int title, int snippet) { map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(getString(title)) .snippet(getString(snippet)) .draggable(true)); } }
/** * Gets a new MarkerOptions object containing styles for the GeoJsonPoint * * @return new MarkerOptions object */ public MarkerOptions toMarkerOptions() { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.alpha(mMarkerOptions.getAlpha()); markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV()); markerOptions.draggable(mMarkerOptions.isDraggable()); markerOptions.flat(mMarkerOptions.isFlat()); markerOptions.icon(mMarkerOptions.getIcon()); markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(), mMarkerOptions.getInfoWindowAnchorV()); markerOptions.rotation(mMarkerOptions.getRotation()); markerOptions.snippet(mMarkerOptions.getSnippet()); markerOptions.title(mMarkerOptions.getTitle()); markerOptions.visible(mMarkerOptions.isVisible()); markerOptions.zIndex(mMarkerOptions.getZIndex()); return markerOptions; }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera mMap.addMarker(new MarkerOptions().position(sydney).title("last online:"+ LastDateOnline)); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,15)); }
@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)); } });
mBrisbane = mMap.addMarker(new MarkerOptions() .position(BRISBANE) .title("Brisbane") .snippet("Population: 2,074,200") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); mSydney = mMap.addMarker(new MarkerOptions() .position(SYDNEY) .title("Sydney") .snippet("Population: 4,627,300") .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)) .infoWindowAnchor(0.5f, 0.5f)); mMelbourne = mMap.addMarker(new MarkerOptions() .position(MELBOURNE) .title("Melbourne") .snippet("Population: 4,137,400") .draggable(true)); mDarwin1 = mMap.addMarker(new MarkerOptions() .position(DARWIN) .title("Darwin Marker 1") .snippet("z-index 1") .zIndex(1)); mDarwin2 = mMap.addMarker(new MarkerOptions() .position(DARWIN) .title("Darwin Marker 2") .snippet("z-index 2") .zIndex(2));
/** * Creates a new marker option from given properties of an existing marker option * * @param originalMarkerOption An existing MarkerOption instance * @param iconRandomColorMode True if marker color mode is random, false otherwise * @param markerColor Color of the marker * @return A new MarkerOption */ private static MarkerOptions createMarkerOptions(MarkerOptions originalMarkerOption, boolean iconRandomColorMode, float markerColor) { MarkerOptions newMarkerOption = new MarkerOptions(); newMarkerOption.rotation(originalMarkerOption.getRotation()); newMarkerOption.anchor(originalMarkerOption.getAnchorU(), originalMarkerOption.getAnchorV()); if (iconRandomColorMode) { float hue = getHueValue(computeRandomColor((int) markerColor)); originalMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(hue)); } newMarkerOption.icon(originalMarkerOption.getIcon()); return newMarkerOption; }
@Override protected void startDemo() { mTextView = (TextView) findViewById(R.id.textView); getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8256, 151.2395), 10)); getMap().setOnMarkerDragListener(this); mMarkerA = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.9046, 151.155)).draggable(true)); mMarkerB = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.8291, 151.248)).draggable(true)); mPolyline = getMap().addPolyline(new PolylineOptions().geodesic(true)); Toast.makeText(this, "Drag the markers!", Toast.LENGTH_LONG).show(); showDistance(); }
@Override public com.google.android.gms.maps.model.MarkerOptions map(MarkerOptions input) { LatLng googleLatLng = AnyMapAdapter.adapt(input.getPosition()); return new com.google.android.gms.maps.model.MarkerOptions() .alpha(input.getAlpha()) .position(googleLatLng) .visible(input.isVisible()) .anchor( input.getAnchorU(), input.getAnchorV() ) .icon( ((BitmapDescriptorAdapter) input.getIcon()).wrappedDescriptor ) .zIndex(input.getZ()); }
private void addMarker(LatLng destination) { MarkerOptions options = new MarkerOptions(); options.position(destination); options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); mMap.addMarker(options); }
public MarkerAreaWrapper(Context context, GoogleMap map, boolean isEnabled, LatLng center, int count, Boolean shouldExpand, ArrayList<Object> locationData, int centerDrawableId) { this.isEnabled = isEnabled; this.count = count; this.mapAreaType = DATA_POINT_WRAPPER; this.shouldExpand = shouldExpand; this.locationData = locationData; centerMarker = map.addMarker(new MarkerOptions() .position(center) .flat(true) .draggable(isEnabled)); if (centerDrawableId != -1) { BitmapDrawable bitmapDrawable = (BitmapDrawable) context.getResources().getDrawable(centerDrawableId); Bitmap bitmap = bitmapDrawable.getBitmap(); Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth()/2, bitmap.getHeight()/2, false); centerMarker.setIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap)); } }
@Override public void updateMarker(@Nullable FusedContact contact) { if (contact == null || !contact.hasLocation() || !isMapReady) { Timber.v("unable to update marker. null:%s, location:%s, mapReady:%s",contact == null, contact == null || contact.hasLocation(), isMapReady); return; } Timber.v("updating marker for contact: %s", contact.getId()); Marker m = mMarkers.get(contact.getId()); if (m != null) { m.setPosition(contact.getLatLng()); } else { m = mMap.addMarker(new MarkerOptions().position(contact.getLatLng()).anchor(0.5f, 0.5f).visible(false)); m.setTag(contact.getId()); mMarkers.put(contact.getId(), m); } contactImageProvider.setMarkerAsync(m, contact); }
com.google.android.gms.maps.model.Marker createMarker(List<Marker> markers, LatLng position) { markerOptions.position(position); ClusterOptions opts = clusterOptionsProvider.getClusterOptions(markers); markerOptions.icon(opts.getIcon()); if (GOOGLE_PLAY_SERVICES_4_0) { try { markerOptions.alpha(opts.getAlpha()); } catch (NoSuchMethodError error) { // not the cutest way to handle backward compatibility GOOGLE_PLAY_SERVICES_4_0 = false; } } markerOptions.anchor(opts.getAnchorU(), opts.getAnchorV()); markerOptions.flat(opts.isFlat()); markerOptions.infoWindowAnchor(opts.getInfoWindowAnchorU(), opts.getInfoWindowAnchorV()); markerOptions.rotation(opts.getRotation()); if (GOOGLE_PLAY_SERVICES_9_2) { try { markerOptions.zIndex(opts.getZIndex()); } catch (NoSuchMethodError error) { GOOGLE_PLAY_SERVICES_9_2 = false; } } return map.addMarker(markerOptions); }
/** * Displays a {@link LiteListDemoActivity.NamedLocation} on a * {@link com.google.android.gms.maps.GoogleMap}. * Adds a marker and centers the camera on the NamedLocation with the normal map type. */ private void setMapLocation() { if (map == null) return; NamedLocation data = (NamedLocation) mapView.getTag(); if (data == null) return; // Add a marker for this item and set the camera map.moveCamera(CameraUpdateFactory.newLatLngZoom(data.location, 13f)); map.addMarker(new MarkerOptions().position(data.location)); // Set the map type back to normal. map.setMapType(GoogleMap.MAP_TYPE_NORMAL); }
@Override protected void onBeforeClusterItemRendered(Person person, MarkerOptions markerOptions) { // Draw a single person. // Set the info window to show their name. mImageView.setImageResource(person.profilePhoto); Bitmap icon = mIconGenerator.makeIcon(); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)).title(person.name); }
public Builder<T> position(LatLng position) { markerOptions.position(position); return this; }
/** * Creates a new PointStyle object */ public GeoJsonPointStyle() { mMarkerOptions = new MarkerOptions(); }
public Builder<T> bitmapDescriptor(BitmapDescriptor bitmap) { markerOptions.icon(bitmap); return this; }
public Builder<T> title(String title) { markerOptions.title(title); return this; }
public Builder<T> snippet(String snippet) { markerOptions.snippet(snippet); return this; }