首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么MyLocationOverlay不能工作?

为什么MyLocationOverlay不能工作?
EN

Stack Overflow用户
提问于 2011-09-03 16:00:53
回答 1查看 738关注 0票数 1

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

代码语言:javascript
复制
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;
    }
}

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-03 20:03:33

确保您的清单中具有ACCESS_FINE_LOCATION权限。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7291909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档