本文整理汇总了Java中com.google.android.gms.maps.model.BitmapDescriptorFactory类的典型用法代码示例。如果您正苦于以下问题:Java BitmapDescriptorFactory类的具体用法?Java BitmapDescriptorFactory怎么用?Java BitmapDescriptorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitmapDescriptorFactory类属于com.google.android.gms.maps.model包,在下文中一共展示了BitmapDescriptorFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initMap
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
private void initMap() {
PlaceAutocompleteFragment autocompleteFragment = new PlaceAutocompleteFragment();
CustomMapFragment mapFragment = new CustomMapFragment();
autocompleteFragment.setOnPlaceSelectedListener(this);
mapFragment.setParent(mBinding.scroll);
mapFragment.getMapAsync(this);
FragmentManager manager = getActivity().getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.place_autocomplete_fragment, autocompleteFragment);
transaction.add(R.id.google_map_fragment, mapFragment);
transaction.commit();
mMarkerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mCircleOptions = new CircleOptions().fillColor(Color.argb(97, 93, 185, 139)).strokeColor(Color.argb(200, 93, 185, 139));
}
示例2: showPointerOnMap
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
private void showPointerOnMap(final double latitude, final double longitude) {
mvRestaurantLocation.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng latLng = new LatLng(latitude, longitude);
googleMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_flag))
.anchor(0.0f, 1.0f)
.position(latLng));
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(true);
// Updates the location and zoom of the MapView
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15);
googleMap.moveCamera(cameraUpdate);
}
});
}
示例3: onMapReady
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@Override
public synchronized void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Start position marker
mMap.addMarker(new MarkerOptions().
position(startCoordinate).
icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
// end position marker
mMap.addMarker(new MarkerOptions().
position(endCoordinate).
icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
if(objectLocations!=null)
for(com.nctu.bikeline.Model.Location objLocation:objectLocations){
mMap.addMarker(new MarkerOptions().position(objLocation.getCoordinate())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
}
// highlight route
mMap.addPolyline(options);
// move and zoom camera
if(gpsService != null)
updateDirectionOverlay(gpsService.getLocation(), 0, false);
}
示例4: addGateway
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
public void addGateway(Packet packet) {
for (Gateway gateway : packet.getGateways()) {
double gwLat = gateway.getLatitude();
double gwLon = gateway.getLongitude();
if (gwLat != 0 && gwLon != 0) {
String gatewayId = gateway.getGatewayID();
if (gatewaysWithMarkers.contains(gatewayId)) {
//already has a marker for this gateway
} else {
MarkerOptions gwoptions = new MarkerOptions();
gwoptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.gateway_dot));
gwoptions.position(new LatLng(gwLat, gwLon));
gwoptions.title(gatewayId);
//gwoptions.snippet(gatewayId);
gwoptions.anchor((float) 0.5, (float) 0.5);
mMap.addMarker(gwoptions);
gatewaysWithMarkers.add(gatewayId);
}
}
}
}
示例5: addColorsToMarkers
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
public static void addColorsToMarkers(GeoJsonLayer layer) {
// Iterate over all the features stored in the layer
for (GeoJsonFeature feature : layer.getFeatures()) {
// Check if the magnitude property exists
if (feature.getProperty("mag") != null && feature.hasProperty("place")) {
double magnitude = Double.parseDouble(feature.getProperty("mag"));
// Get the icon for the feature
BitmapDescriptor pointIcon = BitmapDescriptorFactory
.defaultMarker(magnitudeToColor(magnitude));
// Create a new point style
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
// Set options for the point style
pointStyle.setIcon(pointIcon);
pointStyle.setTitle("Magnitude of " + magnitude);
pointStyle.setSnippet("Earthquake occured " + feature.getProperty("place"));
// Assign the point style to the feature
feature.setPointStyle(pointStyle);
}
}
}
示例6: onBeforeClusterRendered
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@Override
protected void onBeforeClusterRendered(Cluster<IssueMarker> cluster, MarkerOptions options) {
super.onBeforeClusterRendered(cluster, options);
// Cluster customization
Context context = mMap.getContext();
int clusterSize = cluster.getSize();
String clusterIconRes = "cluster1";
for (int i = 0; i < CLUSTER_THRESHOLDS.length; i++) {
int threshold = CLUSTER_THRESHOLDS[i];
if (clusterSize >= threshold) clusterIconRes = "cluster" + (i + 2);
}
mClusterIconGenerator.setBackground(getClusterIcon(context, clusterIconRes));
mClusterIconGenerator.setTextAppearance(R.style.ClusterIconText);
Bitmap sizeIcon = mClusterIconGenerator.makeIcon(String.valueOf(clusterSize));
options.icon(BitmapDescriptorFactory.fromBitmap(sizeIcon));
}
示例7: onLocationChanged
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
//remove previous current location Marker
if (marker != null) {
marker.remove();
}
current_Latitude = mLastLocation.getLatitude();
current_Longitude = mLastLocation.getLongitude();
marker = mMap.addMarker(new MarkerOptions().position(new LatLng(current_Latitude, current_Longitude))
.title("My Location").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(current_Latitude, current_Longitude), 8));
}
示例8: onPostExecute
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@Override
protected void onPostExecute(List<HashMap<String, String>> list) {
googleMap.clear();
for (int i = 0; i < list.size(); i++) {
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = list.get(i);
double lat = Double.parseDouble(googlePlace.get("lat"));
double lng = Double.parseDouble(googlePlace.get("lng"));
String placeName = googlePlace.get("place_name");
//String vicinity = googlePlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(placeName);
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker));
googleMap.addMarker(markerOptions);
}
}
示例9: onLocationChanged
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location)
{
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mGoogleMap.addMarker(markerOptions);
//move map camera
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,11));
}
示例10: Builder
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
public Builder() {
Bitmap toScale = BitmapFactory.decodeResource(
SpaceRace.getAppContext().getResources(),
DEFAULT_PIECE_DISPLAYED);
toScale = Bitmap.createScaledBitmap(toScale,
ICON_DIMENSION,
ICON_DIMENSION,
false);
BitmapDescriptor defaultIcon = BitmapDescriptorFactory.fromBitmap(toScale);
this.firstNodeIcon = defaultIcon;
this.middleNodeIcon = defaultIcon;
this.lastNodeIcon = defaultIcon;
this.map = null;
this.path = null;
}
示例11: drawGraph
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
/**
* @param graph to use in drawing polyOptions on the graph.
*/
@Override
public void drawGraph(Graph graph) {
PolylineOptions graphOptions = new PolylineOptions();
List<Location> locationList = graph.getLocations();
for (Location location: locationList){
LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions options = new MarkerOptions();
options.position(currentPosition)
.icon(BitmapDescriptorFactory.defaultMarker())
.title("Position")
.snippet("Some Position");
googleMap.addMarker(options);
graphOptions.add(currentPosition);
}
Polyline graphPolygon = googleMap.addPolyline(graphOptions);
graphPolygon.setGeodesic(true);
graphPolygon.setColor(Color.DKGRAY);
graphPolygon.setWidth(20);
}
示例12: onLocationChanged
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
@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());
}
}
示例13: getMarker
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
public MarkerOptions getMarker() {
BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_red);
BitmapDescriptor markerIconMobile = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_mobile_red);
this.marker.position(this.getCoordinates());
this.marker.title(this.name);
this.marker.snippet(this.getAddress() + this.getDates());
if(this.isMobile == null) {
this.marker.icon(markerIcon);
} else {
if(this.isMobile == true) {
this.marker.icon(markerIconMobile);
} else {
this.marker.icon(markerIcon);
}
}
return this.marker;
}
示例14: settaMarkersGiaPresenti
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
/**
* Imposta un marker per ogni parcheggio già presente in zona
*/
void settaMarkersGiaPresenti() {
// rimuovi tutti i markers
for(Marker m : mMarkerListPresenti)
m.remove();
mMarkerListPresenti.clear();
// aggiungi un marker per ogni posizione
for (Parcheggio p : ElencoParcheggi.getInstance().getListParcheggi()) {
LatLng coordParcheggio = p.getCoordinate();
Marker marker = mMappa.addMarker(new MarkerOptions()
.position(coordParcheggio)
.title(p.getIndirizzo())
.icon(BitmapDescriptorFactory.defaultMarker(138)));
// Associo al marker un tag che corrisponde al parcheggio in questo modo posso
// poi eliminarlo direttamente
marker.setTag(p);
mMarkerListPresenti.add(marker);
}
mMainActivity.modificaTxtMarkerPresenti(ElencoParcheggi.getInstance().getListParcheggi().size());
}
示例15: moveToPosition
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入依赖的package包/类
private void moveToPosition() {
// add a marker
LatLng wantToGoTo = start;
mMap.clear();
mMap.addMarker(new MarkerOptions().position(wantToGoTo).title(info)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.personstanding)));
// create an animation for map while moving to this location
mMap.animateCamera(CameraUpdateFactory.zoomTo(18), 2000, null);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(wantToGoTo)
.zoom(18)
.bearing(90)
.tilt(30)
.build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}