本文整理汇总了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));
}
}