안드로이드 개발 질문/답변
(글 수 45,052)
edittext에 지명을 입력하면 위도,경도를 가져와 맵에 표시해주는 예제를 해보고 있는데요
맵뷰는 제대로 뜨는것 같은데 지도가 하늘색으로만 표시됩니다 ㅜㅜ
단말기랑 에뮬레이터 둘 다 똑같아요...
매니페스트에 퍼미션 다 줬고, api키도 넣었습니다
검색해보니까 격자무늬로 뜨는 경우에 sign? 해야된다고 해서 그것도 해봤는데 안됩니다 ㅜㅜ
어떻게 하면 지도가 제대로 나오나요... 알려주세요! ㅜㅜ
스샷이랑 소스 첨부할께요!
package yeh.kwu.maptest;
import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Locale;
import android.location.Address; import android.location.Geocoder; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView;
import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView;
public class MapTestActivity extends MapActivity {
double lat= 0f; double lon= 0f; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button bt_gc= (Button)findViewById(R.id.btn_gc); bt_gc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Geocoder gc= new Geocoder(getApplicationContext(), Locale.KOREA); TextView tv= (TextView)findViewById(R.id.tv); EditText edt= (EditText)findViewById(R.id.edt); String placeName= edt.getText().toString(); try{ List<Address> gcResults= gc.getFromLocationName(placeName, 3); Iterator<Address> locations= gcResults.iterator(); String locInfo= "Results: \n"; while(locations.hasNext()){ Address loc= locations.next(); locInfo+= String.format("Location: %f, %f", loc.getLatitude(), loc.getLongitude()); } tv.setText(locInfo); }catch(IOException e){ Log.e("MyError", "Fail!!"); } } }); Button btn_map= (Button)findViewById(R.id.btn_map); btn_map.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MapView map= (MapView)findViewById(R.id.map); final MapController mapControl= map.getController(); // map.setSatellite(true); // map.setBuiltInZoomControls(true); mapControl.setZoom(17); GeoPoint newPoint= new GeoPoint((int)(lat*1E6), (int)(lon*1E6)); mapControl.animateTo(newPoint); MapView.LayoutParams mapMarkerParams= new MapView.LayoutParams(50, 50, newPoint, MapView.LayoutParams.CENTER); ImageView mapMarker= new ImageView(getApplicationContext()); mapMarker.setImageResource(R.drawable.icon); map.addView(mapMarker, mapMarkerParams); } }); }
@Override protected boolean isRouteDisplayed() { return false; } }
바다 같은데요. 지도 확대 축소 기능을 넣으셔서 축소하시면 맵이 다 보이실 거같습니다.