【发布时间】:2018-04-16 15:58:28
【问题描述】:
当我在范围内时,我试图在地图上设置可见标记,当我不在范围内时设置不可见。当移动并进入区域标记出现 - 但当我离开范围标记仍然可见。这是我的代码onLocationUpdate。
我遍历我的数据库并添加标记。 getDeviceLocation 返回Ltglng 与我当前的位置。我也为 GPS 提供商实现了这一点。任何想法都会有所帮助!
locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, new LocationListener() {
@Override
public void onLocationChanged(Location location) {
Cursor res = activityA.myDB.getAllData();
while (res.moveToNext()) {
double ltd = Double.valueOf(res.getString(3));
double lng = Double.valueOf(res.getString(4));
LatLng hole = new LatLng(ltd, lng);
Marker marker = mMap.addMarker(new MarkerOptions().position(hole)
.title(res.getString(1)).visible(false));
if (SphericalUtil.computeDistanceBetween(getDeviceLocation(), marker.getPosition()) <3 ) {
marker.setVisible(true);
}
}
}
【问题讨论】:
标签: android sqlite google-maps marker