3

我想显示特定城市的地图,当用户选择任何城市时,只会显示该城市的区域而不是整个地图。我需要一些建议来做这种事情。提前致谢。

4

4 回答 4

1

您可以通过意图打开地图。

String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

// You can also choose to place a point like so:
String uri = "geo:"+ latitude + "," + longitude + "?q=my+street+address";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

/*
* The Possible Query params options are the following:
*
* Show map at location: geo:latitude,longitude
* Show zoomed map at location: geo:latitude,longitude?z=zoom
* Show map at locaiton with point: geo:0,0?q=my+street+address
* Show map of businesses in area: geo:0,0?q=business+near+city
*/
于 2012-04-25T05:21:45.360 回答
0

首先,您必须要求用户选择一个城市,然后使用Geocoder类查找城市的纬度和经度,使用以下代码

    MapController mControl;
    MapView mapView;
     mapView= (MapView) findViewById(R.id.navView)
     mControl = mapView.getController();
     mControl.animateTo(GeoP); //GeoP is the geopoint of your city
于 2012-05-02T10:05:32.077 回答
0

Here, We need to do RND for each city, what is the latitude & longitude for each city. so for to find latitude & long. for each city no need to go there and check what is the lat. long., The simple way to do is Find coordinates by moving around the map. So After getting all lat. long. for each city. Use this lat. & long. to display map according to the user selection of city. So it will display particular area. So check following code how to use latitude & longitude to display map.

Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("geo:0,0?q=" + ("40.7890011, -124.1719112")));
            try {
                startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
            }

Hope this will help you. Thanks

于 2012-04-25T05:30:54.170 回答
0

为此目的有一个很好的类,称为 Geocoder

这是参考

你可以只使用方法

getFromLocationName("My Particular city", ...) 

并获取与其匹配的位置列表。第一个通常是您需要的。

我想,这是唯一的方法。不过非常有用。:)

希望,它有帮助!)

于 2012-04-25T05:46:58.483 回答