本文整理匯總了Java中com.google.android.gms.maps.model.BitmapDescriptorFactory.defaultMarker方法的典型用法代碼示例。如果您正苦於以下問題:Java BitmapDescriptorFactory.defaultMarker方法的具體用法?Java BitmapDescriptorFactory.defaultMarker怎麽用?Java BitmapDescriptorFactory.defaultMarker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.maps.model.BitmapDescriptorFactory
的用法示例。
在下文中一共展示了BitmapDescriptorFactory.defaultMarker方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: loadMarkers
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //導入方法依賴的package包/類
private void loadMarkers() {
Station[] stations = new Gson().fromJson(GlobalUtils.getString(GlobalUtils.getInputStream("stations.json")), Station[].class);
for (Station station : stations) {
LatLng latLng = new LatLng(station.getLatitud_decimal(), station.getLongitud_decimal());
String snippet = "";
BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);
if (currentPollution != null) {
String stationId = PureMadridContract.PollutionEntry.COLUMN_BASE_STATION + String.format("%02d", station.getId());
double no2Value = getValues(NO2,stationId);
if (no2Value > 0) {
snippet += NO2.name() + ": " + no2Value + " µg/m3";
}
snippet += addStringValue(CO,stationId);
snippet += addStringValue(O3,stationId);
snippet += addStringValue(SO2,stationId);
snippet += addStringValue(PM2_5,stationId);
snippet += addStringValue(PM10,stationId);
snippet += addStringValue(BEN,stationId);
snippet += addStringValue(TOL,stationId);
//
if (no2Value > 400) {
icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);
} else if (no2Value > 200) {
icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE);
} else if (no2Value > 150) {
icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW);
}
if (snippet.equals("")) {
snippet = getString(R.string.no_data_title);
}
}
map.addMarker(
new MarkerOptions()
.icon(icon)
.title(station.getNombre())
.snippet(snippet)
.position(latLng));
}
}