gpt4 book ai didi

android - 为什么 MyLocationOverlay 不起作用?

转载 作者:行者123 更新时间:2023-11-29 18:17:35 24 4
gpt4 key购买 nike

在我的应用程序中,我希望看到当您在谷歌地图中四处走动时跟随您的小蓝点。下面是代码,但是我没有在任何地方看到蓝点,即使我将应用程序导出到我的手机也是如此!

public class UCLAProjectActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapView);
MapController mc = mapView.getController();
int maxLat = (int) (34.07687 * 1E6);
int maxLon = (int) (-118.438239 * 1E6);
int minLat = (int) (34.06489 * 1E6);
int minLon = (int) (-118.452358 * 1E6);
List <Overlay> overlays = mapView.getOverlays();
// "this" refers to your activity
MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
myLocationOverlay.enableMyLocation();
overlays.add(myLocationOverlay);

mc.zoomToSpan(Math.abs(maxLat - minLat), Math.abs(maxLon - minLon));

mc.animateTo(new GeoPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2));
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

谢谢!

最佳答案

确保您在 list 中拥有 ACCESS_FINE_LOCATION 权限。

关于android - 为什么 MyLocationOverlay 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7291909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com