marker.isVisible 为真,但未显示任何标记
marker.isVisible is true, but no marker is showing
我有一张地图,当收到 firebase 消息时,我在上面添加了一个标记。
有时,当我关闭屏幕然后再打开时,我看不到我的标记。
我在 onResume 中有以下代码:
if (situation_ == 3) {
if (marker == null){
Log.i("Logit", "is null");
}else{
Log.i("Logit", String.valueOf(marker.isVisible()));
}
if (marker == null || !marker.isVisible()) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
String Lat = pref.read_pref_info("usera");
String Lng = pref.read_pref_info("userb");
marker_op = new MarkerOptions().position(new LatLng(Double.valueOf(Lat), Double.valueOf(Lng)))
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.marker));
try {
Marker = mMap.addMarker(marker_op);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, 2000);
}
所以我可以在日志中看到标记不为空并且 marker.isVisible returns 为真。
但我在地图上看不到任何标记,如果行:
if (marker == null || !marker.isVisible()) {
来自 documentation.
public boolean isVisible ()
Gets the visibility setting of this marker. Note that this does not
indicate whether the marker is within the screen's viewport. It
indicates whether the marker will be drawn if it is contained in the
screen's viewport.
我有一张地图,当收到 firebase 消息时,我在上面添加了一个标记。 有时,当我关闭屏幕然后再打开时,我看不到我的标记。
我在 onResume 中有以下代码:
if (situation_ == 3) {
if (marker == null){
Log.i("Logit", "is null");
}else{
Log.i("Logit", String.valueOf(marker.isVisible()));
}
if (marker == null || !marker.isVisible()) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
String Lat = pref.read_pref_info("usera");
String Lng = pref.read_pref_info("userb");
marker_op = new MarkerOptions().position(new LatLng(Double.valueOf(Lat), Double.valueOf(Lng)))
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.marker));
try {
Marker = mMap.addMarker(marker_op);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, 2000);
}
所以我可以在日志中看到标记不为空并且 marker.isVisible returns 为真。 但我在地图上看不到任何标记,如果行:
if (marker == null || !marker.isVisible()) {
来自 documentation.
public boolean isVisible ()
Gets the visibility setting of this marker. Note that this does not indicate whether the marker is within the screen's viewport. It indicates whether the marker will be drawn if it is contained in the screen's viewport.