【问题标题】:how to change my first view of the map activity如何更改我对地图活动的第一个视图
【发布时间】:2011-08-24 21:29:49
【问题描述】:

我的应用程序中有一个地图活动。当用户第一次启动地图活动时,地图会显示欧洲的概况。我想,当用户首先启动地图活动以指向希腊而不是洞欧洲..这可能吗..?谢谢

【问题讨论】:

    标签: android google-maps map


    【解决方案1】:

    您可以使用 MapController 来做到这一点:

    MapView map = (MapView) findViewById(R.id.mapview);
    
    GeoPoint center = new GeoPoint(myLatitude, myLongitude);
    
    MapController controller = map.getController();
    controller.setCenter(center);
    controller.setZoom(ZOOM_LEVEL_DEFAULT);
    

    或者如果您想计算适合某个经度/纬度跨度的缩放:

    int latitudeSpan = latitude1 - latitude2;
    int longitudeSpan = longitude1 - longitude2;
    controller.zoomToSpan(latitudeSpan, longitudeSpan);
    

    【讨论】:

    • eclipse 将 map.getController 突出显示为红色,并提示我创建一个变量 map...我怎么了?
    • map 是 MapView 的一个实例。在您的布局 XML 中使用 MapView 的 ID 来创建它。我已经编辑了上面的帖子。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多