파싱을해서 주변을 검색해서 리스트뷰에 출력을 하고 원하는 장소를 하나 클릭해서 그곳에 이름과 주소, 전화번호, 위도,경도 등을 넘겨서 그 좌표에 마커를 출력하는 프로그램을 작성중인데 화욜까지 작성해야합니다. 정말 급해서 질문을 올려봅니다..ㅠ
//여기는 파싱을해서 나온 결과가 나온 listview에서 아이템을 클릭시 발생하는 이벤트
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
String title = items.get(position).getTitle();
String addr = items.get(position).getAddress();
String tel = items.get(position).getTel();
String desc = items.get(position).getDescription();
String dist = (int) items.get(position).getDistance() + " Km";
double lat = items.get(position).getLat();
double lng = items.get(position).getLng();
// 각각 필드에 제목 주소 전화번호거리 표시
Intent intent = new Intent(getApplicationContext(), org.androidtown.googlev2.MapActivity.class);
intent.putExtra("title", title);
intent.putExtra("addr", addr);
intent.putExtra("tel", tel);
intent.putExtra("desc", desc);
intent.putExtra("dist", dist);
intent.putExtra("lat", lat);
intent.putExtra("lng", lng);
startActivity(intent);
}
//google mapv2를 띄우는 소스입니다.
public class MapActivity extends FragmentActivity {
protected GoogleMap gmap;
ImageButton imagebutton,imagebutton2;
protected LatLng position;
protected Intent intent=new Intent();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gmap = ((SupportMapFragment)getSupportFragmentManager().
findFragmentById(R.id.map)).getMap();
init();
}
protected void onResume(){
super.onResume();
init();
}
void init()
{
if(gmap==null)
{
gmap = ((SupportMapFragment)getSupportFragmentManager().
findFragmentById(R.id.map)).getMap(); //액티비티에서 맵을 가져온다.
if(gmap!=null)
{
addMarker();
}
}
}
void addMarker()
{
intent = getIntent();
double lat = intent.getDoubleExtra("lat", 0);
double lng = intent.getDoubleExtra("lng", 0);
String title=intent.getStringExtra("title");
String addr= intent.getStringExtra("addr");
String tel= intent.getStringExtra("tel");
String desc= intent.getStringExtra("desc");
String dist= intent.getStringExtra("dist");
position=new LatLng(lat, lng);
gmap.addMarker(new MarkerOptions().position(position).title(title).snippet(dist+"km").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
gmap.moveCamera(CameraUpdateFactory.newLatLng(position));
}
//혹시 manifest에 에러가 있을꺼 같기도 해서 manifest도올려봅니다.
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission android:protectionLevel="signature" android:name="org.androidtown.permission.MAPS_RECEIVE"></permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="org.androidtown.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="@drawable/pin"
android:label="@string/app_name"
>
<activity
android:name="org.androidtown.navermap.MainActivity"
android:label="위치 검색"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="org.androidtown.googlev2.MapActivity"></activity>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCrRAyIBgkzCgzm0rMGHu8mXbQUZMmVnOY"/>
</application>
//마지막으로 logcat도 올려봅니다. 마지막줄에 failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).이것이 뜨길래 연결이 안됐나?? 싶어서 연결까지 확인을 했는데도
06-23 23:13:37.233: D/memalloc(11703): ion: Mapped buffer base:0x5c27c000 size:327680 offset:0 fd:77
06-23 23:13:37.283: D/memalloc(11703): ion: Mapped buffer base:0x5c2cc000 size:4096000 offset:0 fd:81
06-23 23:13:37.353: D/memalloc(11703): ion: Mapped buffer base:0x5c7b4000 size:327680 offset:0 fd:84
06-23 23:13:37.843: W/System.err(11703): java.lang.NullPointerException
06-23 23:13:37.843: W/System.err(11703): at org.androidtown.navermap.ItemParser.xmlParser2(ItemParser.java:164)
06-23 23:13:37.853: W/System.err(11703): at org.androidtown.navermap.ItemParser.setLatLong(ItemParser.java:127)
06-23 23:13:37.853: W/System.err(11703): at org.androidtown.navermap.ItemParser.xmlParser(ItemParser.java:109)
06-23 23:13:37.853: W/System.err(11703): at org.androidtown.navermap.MainActivity$2.run(MainActivity.java:196)
06-23 23:13:38.284: D/memalloc(11703): ion: Mapped buffer base:0x5c804000 size:4096000 offset:0 fd:76
06-23 23:13:38.314: D/memalloc(11703): ion: Unmapping buffer base:0x5c27c000 size:327680
06-23 23:13:38.324: D/memalloc(11703): ion: Unmapping buffer base:0x5c7b4000 size:327680
06-23 23:13:43.288: I/Adreno200-EGLSUB(11703): <ConfigWindowMatch:2176>: Format RGBX_8888.
06-23 23:13:43.288: D/memalloc(11703): ion: Mapped buffer base:0x5e44a000 size:4096000 offset:0 fd:127
06-23 23:13:43.308: D/memalloc(11703): ion: Mapped buffer base:0x5e832000 size:3788800 offset:0 fd:130
06-23 23:13:43.338: E/(11703): Can't open file for reading
06-23 23:13:43.348: E/(11703): Can't open file for reading
06-23 23:13:43.359: D/memalloc(11703): ion: Unmapping buffer base:0x5c2cc000 size:4096000
06-23 23:13:43.359: D/memalloc(11703): ion: Unmapping buffer base:0x5c804000 size:4096000
06-23 23:13:43.529: D/memalloc(11703): ion: Mapped buffer base:0x5c7f7000 size:3788800 offset:0 fd:82
06-23 23:13:43.539: D/memalloc(11703): ion: Mapped buffer base:0x5f13c000 size:3788800 offset:0 fd:88
06-23 23:13:45.471: I/Google Maps Android API(11703): Failed to contact Google servers. Another attempt will be made when connectivity is established.
06-23 23:13:45.821: E/Google Maps Android API(11703): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

//결과입니다..
음 정말 다른 버그는 logcat과 구글링을 이용해서 얼추 잡았는데.. 음.. 도대체 무슨 원인인지 모르겠습니다..ㅠㅠ