2012-04-25 41 views

回答

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 
*/ 
0

在这里,我们需要为每个城市做RND,什么是纬度经度&每个城市。所以为了找到纬度&长。每个城市都不需要去那里检查什么是经纬度。长,简单的方法是Find coordinates by moving around the 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(); 
      } 

希望这会对你有帮助。由于

0

没有为这一目的,即GeoCoder

善类下面是reference

你可以只使用方法

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

,并获得与之匹配的地点列表。第一个通常是你需要的。

我想这是唯一的方法。虽然非常有用。 :)

希望,它帮助!)

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 
相关问题