本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.addMarker方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.addMarker方法的具体用法?Java GoogleMap.addMarker怎么用?Java GoogleMap.addMarker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.GoogleMap
的用法示例。
在下文中一共展示了GoogleMap.addMarker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMarkers
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void setMarkers(GoogleMap map, List<Restaurant> restaurants) {
if (map == null) {
return;
}
map.clear();
MarkerOptions options = new MarkerOptions().position(
new LatLng(Prefs.LastLatitude.getDouble(), Prefs.LastLongitude.getDouble()))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.current_location));
map.addMarker(options);
for (Restaurant restaurant : restaurants) {
MarkerOptions markerOptions = new MarkerOptions().position(
new LatLng(restaurant.mLatitude, restaurant.mLongitude))
.title(restaurant.mName)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.restaurant_pin));
Marker marker = map.addMarker(markerOptions);
marker.setTag(restaurant);
}
mMap.setOnInfoWindowClickListener(mInfoWindowClickListener);
}
示例2: addTag
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void addTag(Context context, GoogleMap map, TagModel item, boolean addCache) {
LatLng location = new LatLng(item.getLatitude(), item.getLongitude());
BitmapDescriptor tagIcon = getTagIcon(item.getRoadCondition());
Marker marker = map.addMarker(new MarkerOptions()
.position(location)
.icon(tagIcon)
.anchor(0.5f, 0.5f)
.title(item.getName())
.snippet(item.getDescription()));
if (addCache && markersCache != null) {
markersCache.put(marker, item);
}
}
示例3: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Run this code when the map has been loaded and is ready
* @param googleMap the map
*/
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
googleMap.setLatLngBoundsForCameraTarget(null);
googleMap.setMinZoomPreference(6.0f);
// Add a marker in Sydney, Australia,
// and move the map's camera to the same location.
if(location != null) {
LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());
map.addMarker(new MarkerOptions().position(loc)
.title("Location"));
map.moveCamera(CameraUpdateFactory.newLatLng(loc));
} else {
LatLng sydney = new LatLng(-33.852, 151.211);
googleMap.addMarker(new MarkerOptions().position(sydney)
.title("Location"));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
示例4: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setMapToolbarEnabled(false);
LatLng latLng = mPointOfInterest.latLng;
if (latLng != null) {
googleMap.addMarker(new MarkerOptions().position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16f));
}
}
示例5: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
float zoomLevel = (float) 16.0;
LatLng coordenadas = new LatLng(evento.getLatitud(), evento.getLongitud());
googleMap.addMarker(new MarkerOptions().position(coordenadas).title(evento.getTitulo()));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(coordenadas, zoomLevel));
}
示例6: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
float zoomLevel = (float) 16.0;
LatLng coordenadas = new LatLng(region.getLatitud(), region.getLongitud());
googleMap.addMarker(new MarkerOptions().position(coordenadas).title(region.getNombre()));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(coordenadas, zoomLevel));
}
示例7: setIntersection
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private static void setIntersection(Context context, GoogleMap gMap, LatLng latLng) {
Marker marker = gMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrow)));
mIntersectingToClear.add(marker);
DatabaseHelper myDb = DatabaseHelper.getInstance(context);
myDb.saveIntersections(mIntersecting);
myDb.close();
}
示例8: setSpawnPoint
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public static void setSpawnPoint(final Context context, final GoogleMap googleMap, final LatLng latLng){
Marker marker = googleMap.addMarker(new MarkerOptions()
.position(latLng));
marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
mSpawnPoints.add(marker);
// Put location into the database as 2 doubles with type Spawn Location.
DatabaseHelper myDb = DatabaseHelper.getInstance(context);
myDb.addLocation("Spawn Location", latLng.latitude, latLng.longitude, "No Description");
myDb.close();
}
示例9: showSpawnLocations
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private static void showSpawnLocations(GoogleMap googleMap, LatLng latLng, String description, String time) {
Marker marker = googleMap.addMarker(new MarkerOptions().position(latLng));
marker.setSnippet(description);
marker.setTag(time + "");
marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
mSpawnPoints.add(marker);
if (marker.getTag() != "") {
mSpawnPointTimes.add(marker);
}
}
示例10: addAllMarkers
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Adds a marker for each event with a location.
* @param map
*/
private void addAllMarkers(GoogleMap map){
for (HabitEvent e:events){
if ((e.getLat()!=null && e.getLong()!=null) && (e.getLat()!=0 && e.getLong()!=0)){
map.addMarker(new MarkerOptions()
.position(new LatLng(e.getLat(), e.getLong()))
.title(e.getHabitType()));
}
}
}
示例11: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(eve.getPlace().getLat(),eve.getPlace().getLon()))
.zoom(17)
.bearing(0)
.tilt(80)
.build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
googleMap.addMarker(new MarkerOptions().position(new LatLng(eve.getPlace().getLat(),eve.getPlace().getLon())));
}
示例12: addImageMarker
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void addImageMarker(MFBImageInfo mfbii, LatLngBounds.Builder llb) {
Bitmap bmap = MFBImageInfo.getRoundedCornerBitmap(mfbii.bitmapFromThumb(), Color.LTGRAY, RadiusImage, BorderImage, DimensionImageOverlay, DimensionImageOverlay, ActFlightMap.this);
Marker m;
GoogleMap map = getMap();
if (map != null && (m = map.addMarker(new MarkerOptions()
.position(mfbii.Location.getLatLng())
.title(mfbii.Comment)
.icon(BitmapDescriptorFactory.fromBitmap(bmap)))) != null) {
m_hmImages.put(m.getId(), mfbii);
if (llb != null)
llb.include(mfbii.Location.getLatLng());
}
}
示例13: setUpMap
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public void setUpMap(GoogleMap googleMap) {
LatLng pinPosition = new LatLng(rack.getLatitude(), rack.getLongitude());
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pinPosition, 18));
googleMap.addMarker(new MarkerOptions()
.position(pinPosition)
.icon(AssetHelper.getCustomPin(rack.getAverageRating(), false)));
}
示例14: addBump
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void addBump(Context context, GoogleMap map, BumpModel item, boolean addCache) {
LatLng location = new LatLng(item.getLatitude(), item.getLongitude());
if (bumpIcon == null) {
bumpIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_bump_red);
}
Marker marker = map.addMarker(new MarkerOptions()
.position(location)
.icon(bumpIcon)
.anchor(0.5f, 0.5f)
.title(item.getName())
.snippet(item.getDescription()));
if (addCache && markersCache != null) {
markersCache.put(marker, item);
}
}
示例15: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
Marker marker = googleMap.addMarker(new MarkerOptions().position(location)
.title(descriptionString));
marker.showInfoWindow();
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 20));
}