MyLocationOverlay 未出现

发布于 2024-10-08 08:07:24 字数 610 浏览 0 评论 0原文

当我调用此方法时,蓝点不会出现在地图上,直到我从 ddms 发送位置, 然后它突然出现了。

    private void findMyLocation(final Location location){
    final MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();
    final GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6),
            (int) (location.getLongitude() * 1E6));
    controller.animateTo(point);
    controller.setCenter(point);
    mapView.getOverlays().add(myLocationOverlay);
    mapView.postInvalidate();
}

调用此方法后如何立即显示该蓝点? 多谢。

when I call this method the blue dot is not appearing on the map, until i send location from ddms,
then suddenly it appears.

    private void findMyLocation(final Location location){
    final MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();
    final GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6),
            (int) (location.getLongitude() * 1E6));
    controller.animateTo(point);
    controller.setCenter(point);
    mapView.getOverlays().add(myLocationOverlay);
    mapView.postInvalidate();
}

how can i show that blue dot right after calling this method?
thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2024-10-15 08:07:24

如何在调用此方法后立即显示该蓝点?

你不能。

MyLocationOverlay,顾名思义,显示用户的位置。如果设备/模拟器不知道用户的位置,则无法显示。

就设备而言,在确定用户的位置(例如,GPS)之前,它不会显示用户的位置。

在模拟器的情况下,它不会显示用户的位置,直到它确定所述位置(例如,DDMS)。

how can i show that blue dot right after calling this method?

You can't.

MyLocationOverlay, as its name suggests, shows the user's location. If the device/emulator does not know the user's location, it cannot show it.

In the case of the device, it will not show the user's location until it has determined said location (e.g., GPS).

In the case of the emulator, it will not show the user's location until it has determined said location (e.g., DDMS).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文