开发者

Center map using MyLocationOverlay

How can I center the map on my current location overlay. I have enableMyL开发者_开发百科ocation(); and there is a blue dot. How can I center on the blue dot?

The reason is that it takes a while to get GPS location from the Location Manager. So I have the blue location dot already displayed but still cannot move the map to my location. Right now it's tied to the GPS/location manager.


Another late answer, but works the best for the purpose. Use runOnMyFirstFix() this callback will be run when your overlay does get the location on you.. Where me is your instance of MyLocationOverlay

me.runOnFirstFix(new Runnable() {
    public void run() {
        mMapView.getController().animateTo(me.getMyLocation());
    }
});

Now, you don' have keep checking.. it just does it automagically.


Perhaps a late answer, but this is what I use.

private void CenterToUserLocation()
{
    if(this.myLoc.getLastFix() != null) 
    {
        this.mc.animateTo(this.myLoc.getMyLocation());
    } else
    {
        Toast.makeText(this, "Location not yet found", Toast.LENGTH_LONG).show();
    }
}

As for the second part of the question, I don't understand that. How is the map tied to the GPS/location manager?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜