2011-06-21 13 views
0

可能性の重複:ここ エディットテキストから地名を取得し、地図上に配置


i am getting null pointer exception from String placeName = placeText.getText().toString();

は、警告ダイアログボックスから地名を取るための私のコードであると私はマークしたいです地図上の地名。どのように私はもっと行くことができます私を助けてくださいできます。これらのマークから入力を取ることによって、場所の地図。 。 AlertDialog.Builderダイアログ=新しいAlertDialog.Builder(this); dialog.setTitle( "場所を入力してください"); dialog.setView(layout);

  final EditText placeText = (EditText)layout.findViewById(R.id.strtplace); 
      final String placeName = placeText.getText().toString(); 
      dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 



       @Override 
       public void onClick(DialogInterface dialog, int id) { 
        // TODO Auto-generated method stub 

        //Break from execution if the user has not entered anything in the field 
         if(placeName.compareTo("")==0) 
         numberOptions = 5; 
         String [] optionArray = new String[numberOptions]; 
         Geocoder gcoder = new Geocoder(TravellogActivity.this); 

         try{ 
          List<Address> results = gcoder.getFromLocationName(placeName,numberOptions); 
          Iterator<Address> locations = results.iterator(); 
          String raw = "\nRaw String:\n"; 
          String country; 
          int opCount = 0; 
          while(locations.hasNext()){ 
           Address location = locations.next(); 
           lat = location.getLatitude(); 
           lon = location.getLongitude(); 
           country = location.getCountryName(); 
           if(country == null) { 
            country = ""; 
           } else { 
            country = ", "+country; 
           } 
           raw += location+"\n"; 
           optionArray[opCount] = location.getAddressLine(0)+", "+location.getAddressLine(1)+country+"\n"; 
           opCount ++; 
          } 
          Log.i("Location-List", raw); 
          Log.i("Location-List","\nOptions:\n"); 
          for(int i=0; i<opCount; i++){ 
           Log.i("Location-List","("+(i+1)+") "+optionArray[i]); 
          } 

         } catch (IOException e){ 
          Log.e("Geocoder", "I/O Failure; is network available?",e); 
         }   

           // p = new GeoPoint((int)(latE6),(int)(lonE6)); 


        }      
       }); 

      dialog.show(); 
      break; 

      } 



     return false ; 

     } 

答えて

0

任意のビューを地図上に追加する場合は、Google提供のjarファイルで定義されているMapOverlayクラスを使用する必要があります。

このlink.Thisは簡単な変更

http://www.bogotobogo.com/Android/android17MapView.html

であなたの問題を解決することがありますフォロー
関連する問題