2017-06-01 23 views
1

我想打开谷歌地图时,我有地址:当我有一个国家,城市,街道,建筑物数量。我只能打开一个谷歌地图,当我有一个经纬度。我如何做到这一点?Java android打开谷歌地图与地址

+0

没有人知道。全部取决于你的代码。 –

+0

@VladMatvienko,但我可以将整个地址geogoding到纬度?或者我可以用地址打开谷歌地图; Polska,克拉科夫,Teligi 13? –

+1

你可以同时做这两件事。获取地址的经纬度:https://www.google.com.ua/search?q=android+get+latitude+and+longitude+from+address&oq=android+get+latitude+and+longitude+ &aqs = chrome.4.69i57j0l5.8479j0j7&sourceid = chrome&ie = UTF-8。要打开地图,请使用以下地址:https://www.google.com.ua/search?q=android+get+latitude+and+longitude+from+address&oq=android+get+latitude+and+longitude+&aqs=chrome .4.69i57j0l5.8479j0j7&的SourceID =铬&即= UTF-8#安全=关闭&q =机器人+开放+谷歌地图+ + +用的+地址 –

回答

4

您可以通过坐标得到利用地理编码后开放谷歌地图从ADRESS坐标

类似的东西

当你拥有所有
mMap = ((SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map)).getMap(); 

    Log.v("ddd", mAddress); 

    Geocoder geocoder = new Geocoder(this, Locale.getDefault()); 
      //To initialice list of address 
    List<Address> addresses = null; 
    try { 
        //To put the address in list 
     addresses = geocoder.getFromLocationName(mAddress, 1); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
      //Get Latitude and longitude 
    Address address = addresses.get(0); 
    mLongitude = address.getLongitude(); 
    mlatitude = address.getLatitude(); 
1
Here it's really simple to launch google maps from your application: 
//geo:0,0 if you don't have lat/lng for the location and just wanna search using address. 

Uri gmmIntentUri = Uri.parse("geo:0,0?q=pass the address here"); 
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); 
//set package to "com.google.android.apps.maps" so that only google maps is opened. 
mapIntent.setPackage("com.google.android.apps.maps"); 
startActivity(mapIntent);