开发者

MyLocationOverlay doesn't appear

开发者 https://www.devze.com 2023-01-31 08:17 出处:网络
when I call this method the blue dot is not appearing on the map, until i send location from ddms, then suddenly it appears.

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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号