我正在使用MyLocationNewOverlay
来显示用户的当前位置。当第一次找到该位置时,我已经设法放置了一个标记(例如,当runOnFirstFix()
调用该函数时:
/* set start location */
mapController = mapView.getController();
mapController.setZoom(12);
GeoPoint startPoint = new GeoPoint(mucLocation.latitude, mucLocation.longitude);
mapController.setCenter(startPoint);
/* MyLocation overlay */
mLocationOverlay = new MyLocationNewOverlay(mapView);
mLocationOverlay.enableMyLocation();
// mLocationOverlay.enableFollowLocation();
mLocationOverlay.setDrawAccuracyEnabled(true);
mLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
Log.e("Location", "runOnFirstFix");
mapController.animateTo(mLocationOverlay.getMyLocation());
Marker currentLocation = new Marker(mapView);
currentLocation.setIcon(ContextCompat.getDrawable(mContext, R.drawable.ic_location));
currentLocation.setPosition(mLocationOverlay.getMyLocation());
currentLocation.setTitle("Hier bin ich");
mapView.getOverlays().add(currentLocation);
}
});
现在我想在收到位置更新时更新标记的位置。据我所知,这是不可能的MyLocationOverlay
,但我希望新的MyLocationNewOverlay
. 在 文档中,我看到有enableMyLocation()
允许接收位置更新,并且enableFollowLocation()
可以将地图保持在当前位置的中心。因此,覆盖似乎已经能够提供定期的位置更新。
我知道我可以使用 Android 的LocationListener
,但似乎这个功能已经在里面,MyLocationNewOverlay
因为它能够跟随位置。
有谁知道是否有办法通过该叠加层接收位置更新,并可以举例说明如何做到这一点?我注意到了这个 MyLocationNewOverlay.onLocationChanged()
功能,但不知道如何使用它。有任何想法吗?