本文整理汇总了Java中com.mapbox.mapboxsdk.annotations.Marker.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setIcon方法的具体用法?Java Marker.setIcon怎么用?Java Marker.setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mapbox.mapboxsdk.annotations.Marker
的用法示例。
在下文中一共展示了Marker.setIcon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resizeSurroundingMarkers
import com.mapbox.mapboxsdk.annotations.Marker; //导入方法依赖的package包/类
private void resizeSurroundingMarkers() {
if (isAdded() && mMap != null && mSurroundingMarkers != null && mSurroundingMarkers.size() > 0) {
int iconSize = calculateMarkerIconSize();
if (iconSize != mLastIconSize) {
Icon circle = Utils.drawableToIcon(getActivity(), R.drawable.ic_marker, iconSize);
for (Marker marker : mSurroundingMarkers) {
marker.setIcon(circle);
}
mLastIconSize = iconSize;
}
}
}
示例2: updateMap
import com.mapbox.mapboxsdk.annotations.Marker; //导入方法依赖的package包/类
private void updateMap(String uid, JSONArray measurement)
{
if (alert_in_progress) {
// We don't want to interfere with a general alert
return;
}
// A new event is coming
resetMarkerTimer.cancel();
updateLastActive();
final ArrayList<String> places = new ArrayList<>();
IconFactory mIconFactory = IconFactory.getInstance(this);
Drawable mIconDrawableDanger = ContextCompat.getDrawable(this, R.drawable.map_yellow);
Icon warning_icon = mIconFactory.fromDrawable(mIconDrawableDanger);
for (final Marker marker : listOfMarkers) {
if (marker.getSnippet().equals(uid)) {
places.add(marker.getTitle());
marker.setIcon(warning_icon);
runOnUiThread(new Runnable() {
@Override
public void run() {
mapView.removeMarker(marker);
mapView.addMarker(new MarkerOptions()
.position(marker.getPosition())
.title(marker.getTitle())
.icon(marker.getIcon())
.snippet(marker.getSnippet()));
}
});
}
}
// Update msg box
runOnUiThread(new Runnable() {
@Override
public void run() {
msg.setText(String.format(getString(R.string.measurement_event), TextUtils.join(", ", places)));
msgbox.setBackgroundColor(getResources().getColor(R.color.warning));
}
});
// Run for 2 seconds
resetMarkerTimer = new Timer();
resetMarkerTimer.schedule(new TimerTask() {
@Override
public void run() {
if (!alert_in_progress) {
resetStillMarkers();
}
resetMarkerTimer.cancel();
}
}, WARNING_DISPLAY_TIME_IN_S*1000);
}
示例3: showAlert
import com.mapbox.mapboxsdk.annotations.Marker; //导入方法依赖的package包/类
private void showAlert(JSONObject alert)
{
// A new event is coming
resetMarkerTimer.cancel();
alert_in_progress = true;
String tmp;
JSONArray sensor_uids;
List<String> uids_list = new ArrayList<>();
updateLastActive();
try {
tmp = alert.get("message").toString();
} catch(Exception e) {
tmp = getString(R.string.general_alert);
}
try {
sensor_uids = (JSONArray) alert.get("sensors_uids");
//noinspection StatementWithEmptyBody
for (int i = 0; i < sensor_uids.length();uids_list.add(sensor_uids.get(i++).toString()));
} catch(Exception ignored) {
}
IconFactory mIconFactory = IconFactory.getInstance(this);
Drawable mIconDrawableDanger = ContextCompat.getDrawable(this, R.drawable.map_red);
Icon danger_icon = mIconFactory.fromDrawable(mIconDrawableDanger);
for (final Marker marker : listOfMarkers) {
if (uids_list.contains(marker.getSnippet())) {
marker.setIcon(danger_icon);
runOnUiThread(new Runnable() {
@Override
public void run() {
mapView.removeMarker(marker);
mapView.addMarker(new MarkerOptions()
.position(marker.getPosition())
.title(marker.getTitle())
.icon(marker.getIcon())
.snippet(marker.getSnippet()));
}
});
}
}
final String message = tmp;
// Update msg box with alert
runOnUiThread(new Runnable() {
@SuppressLint("PrivateResource")
@Override
public void run() {
msg.setText(message);
msg.setTextColor(getResources().getColor(R.color.white));
msgbox.setBackgroundColor(getResources().getColor(R.color.danger));
}
});
// Run for 2 seconds
resetAlertTimer = new Timer();
resetAlertTimer.schedule(new TimerTask() {
@Override
public void run() {
resetStillMarkers();
resetAlertTimer.cancel();
alert_in_progress = false;
}
}, ALERT_DISPLAY_TIME_IN_S*1000);
}
示例4: hideMarker
import com.mapbox.mapboxsdk.annotations.Marker; //导入方法依赖的package包/类
public void hideMarker(Marker marker) {
marker.setIcon(IconFactory.getInstance(getActivity()).fromResource(R.drawable.hidden_marker));
}