Spo*_*Bob 2 null conditional-statements google-maps-api-3 marker
我想通过谷歌地图实现一些东西,我需要知道setMap是否已设置或为空.我怎样才能实现这样的事情:
if (marker.setMap == null)
{
marker.setMap(map);
}
Run Code Online (Sandbox Code Playgroud)
你必须调用getMap函数,而不是检查setMap函数是否为null.这将切换标记:
if (marker.getMap() == null) marker.setMap(map);
else marker.setMap(null);
Run Code Online (Sandbox Code Playgroud)
甚至
if (!marker.getMap()) marker.setMap(map);
else marker.setMap(null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3268 次 |
| 最近记录: |