我有一张 map ,当收到火力按摩时,我在上面添加了一个标记。 有时,当我关闭屏幕然后再打开时,我看不到我的标记。
我在 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返回true。 但我在 map 上看不到任何标记,并且它不会出现在该 if 行中:
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.
关于java - marker.isVisible 为 true,但没有显示任何标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46132479/