本文整理了Java中com.google.android.gms.maps.model.Marker.setTag()
方法的一些代码示例,展示了Marker.setTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marker.setTag()
方法的具体详情如下:
包路径:com.google.android.gms.maps.model.Marker
类名称:Marker
方法名:setTag
暂无
代码示例来源:origin: facebook/facebook-android-sdk
private void displayPlacesOnMap(List<Place> places) {
if (map != null) {
map.clear();
if (!places.isEmpty()) {
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (Place place : places) {
// Creates a marker at the place location and with the place name
LatLng position = place.getPosition();
String placeName = place.get(Place.NAME);
if (position != null) {
MarkerOptions markerOptions = new MarkerOptions()
.position(position)
.title(placeName);
Marker marker = map.addMarker(markerOptions);
marker.setTag(place);
boundsBuilder.include(position);
}
}
CameraUpdate cameraUpdate =
CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 100);
map.moveCamera(cameraUpdate);
}
}
}
代码示例来源:origin: mg6maciej/android-maps-extensions
@Deprecated
public void setTag(Object tag) {
createMarker();
marker.setTag(tag);
}
代码示例来源:origin: googlemaps/android-samples
mHobartMarker.setTag(new CustomTag("Hobart marker"));
代码示例来源:origin: Bhoomika06/Styled-Map-Pager
private void addNearerPin(MyLocation mLocation, int position) {
LatLng locationPoint = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
// map.moveCamera(CameraUpdateFactory.newLatLng(locationPoint));
if (googleMap.getCameraPosition().zoom >= 13) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_near_normal_pin)))).setTag(position);
} else if (googleMap.getCameraPosition().zoom < 13) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_normal_pin)))).setTag(position);
}
}
代码示例来源:origin: Bhoomika06/Styled-Map-Pager
private void addMarkerSelectedPin(MyLocation mLocation, int position, int selectedPosition) {
LatLng locationPoint = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
// map.moveCamera(CameraUpdateFactory.newLatLng(locationPoint));
if (position == selectedPosition) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_selected_pin)))).setTag(position);
} else {
if (googleMap.getCameraPosition().zoom >= 13) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_near_normal_pin)))).setTag(position);
} else if (googleMap.getCameraPosition().zoom < 13) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_normal_pin)))).setTag(position);
}
}
}
代码示例来源:origin: google-developer-training/android-advanced
@Override
public void onPoiClick(PointOfInterest poi) {
Marker poiMarker = map.addMarker(new MarkerOptions()
.position(poi.latLng)
.title(poi.name));
poiMarker.showInfoWindow();
poiMarker.setTag(getString(R.string.poi));
}
});
代码示例来源:origin: bkhezry/MapDrawingTools
private void updateMarkerLocation(Marker marker, boolean calculate) {
LatLng latLng = (LatLng) marker.getTag();
int position = points.indexOf(latLng);
points.set(position, marker.getPosition());
marker.setTag(marker.getPosition());
if (drawingOption.getDrawingType() == DrawingOption.DrawingType.POLYGON) {
drawPolygon(points);
if (calculate)
setAreaLength(points);
} else if (drawingOption.getDrawingType() == DrawingOption.DrawingType.POLYLINE) {
drawPolyline(points);
if (calculate)
setLength(points);
}
}
代码示例来源:origin: bkhezry/MapDrawingTools
@Override
public void onMapClick(LatLng latLng) {
@IdRes int icon = R.drawable.ic_add_location_light_green_500_36dp;
BitmapDescriptor bitmap = BitmapDescriptorFactory.fromBitmap(getBitmapFromDrawable(MapsActivity.this, icon));
Marker marker = mMap.addMarker(new MarkerOptions().position(latLng).icon(bitmap).draggable(true));
marker.setTag(latLng);
markerList.add(marker);
points.add(latLng);
if (drawingOption.getDrawingType() == DrawingOption.DrawingType.POLYGON) {
drawPolygon(points);
setAreaLength(points);
} else if (drawingOption.getDrawingType() == DrawingOption.DrawingType.POLYLINE) {
drawPolyline(points);
setLength(points);
}
}
});
代码示例来源:origin: Bhoomika06/Styled-Map-Pager
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_near_normal_pin)))).setTag(position);
} else if (googleMap.getCameraPosition().zoom < 13) {
googleMap.addMarker(new MarkerOptions().position(locationPoint).icon(BitmapDescriptorFactory.fromBitmap(
BitmapFactory.decodeResource(mContext.getResources(),
R.drawable.ic_normal_pin)))).setTag(position);
代码示例来源:origin: owntracks/android
@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);
}
内容来源于网络,如有侵权,请联系作者删除!