2016-04-29 8 views
0

私のアプリにはGoogleマップのアクティビティがあります。 場所の特定の住所を入力したいと思います。アプリにGoogleマップマーカーを作成させたいのですが。今まで、私はこのように、緯​​度経度タラをGoogle Map Markerに特定のアドレスを設定する

を入れている:

double location_left = Double.parseDouble(leftLocation); 
double location_right = Double.parseDouble(rightLocation); 
String place_title = child.child("place/place_title").getValue().toString(); 
LatLng cod = new LatLng(location_left, location_right); 
googleMap.addMarker(new MarkerOptions().position(cod).title(place_title)); 

は緯度経度タラに、この「隠密セントニューヨーク、アメリカ」のような特定のアドレスを作るのいずれかのオプションがありますか?またはGoogleの地図のマーカーに?

+0

はhttp://stackoverflow.com/questions/24352192/を参照してください。 android-google-maps-add-marker-by-address – sasikumar

答えて

0

入力アドレスのこの関数の戻りGoogleマップ画像は、あなたが直接、ピカソの助けを借りて、アドレスの画像のURLをロードまたはグライドかあればできる緯度経度

public static String getLocationURLFromAddress(Context context, 
     String strAddress) { 

    Geocoder coder = new Geocoder(context); 
    List<android.location.Address> address; 
    LatLng p1 = null; 

    try { 
     address = coder.getFromLocationName(strAddress, 5); 
     if (address == null) { 
      return null; 
     } 
     android.location.Address location = address.get(0); 
     location.getLatitude(); 
     location.getLongitude(); 

     return "http://maps.googleapis.com/maps/api/staticmap?zoom=18&size=560x240&markers=size:mid|color:red|" 
       + location.getLatitude() 
       + "," 
       + location.getLongitude() 
       + "&sensor=false"; 

     // 
     // p1 = new LatLng(location.getLatitude(), location.getLongitude()); 

    } catch (Exception ex) { 

     ex.printStackTrace(); 
    } 
    return strAddress; 

    // return p1; 
} 

を返すためにそれを変更することができます地図にマーカーを作りたいあなたはこのような何かを行うことができます: -

private void addMarker(LatLng currentLatLng) { 

      MarkerOptions options = new MarkerOptions(); 

      // following four lines requires 'Google Maps Android API Utility Library' 
      // https://developers.google.com/maps/documentation/android/utility/ 
      // I have used this to display the time as title for location markers 
      // you can safely comment the following four lines but for this info 

      IconGenerator iconFactory = new IconGenerator(this); 

      iconFactory.setStyle(IconGenerator.STYLE_PURPLE); 
      options.icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(mLastUpdateTime))); 
      options.anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV()); 


      Marker mapMarker = googleMap.addMarker(options); 

      long atTime = mCurrentLocation.getTime(); 

      mLastUpdateTime = DateFormat.getTimeInstance().format(new Date(atTime)); 

      mapMarker.setTitle(mLastUpdateTime); 

      Log.d(TAG, "Marker added............................."); 
      googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 
        13)); 
      Log.d(TAG, "Zoom done............................."); 
     } 
関連する問題