잘 사용하던 네이버 지도가 갑자기 제대로 띄우질 못합니다...
데이터베이스 쪽 건드리면서 이쪽은 손도 안댔는데...
데이터베이스 해결하고 나니 엉뚱하게 이놈이 말썽이네요..
주소를 찾지 못하고 대한민국 전체 지도만 띄워주네요...;;;
뭐가 문제일까요 ㅜ
Button btnMap = (Button)findViewById(R.id.earth);
btnMap.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
////////////////////주소로 좌표얻기/////////////////////////////////
Intent intent = new Intent(Customer.this, NaverMap.class);
TextView cusAddress = (TextView)findViewById(R.id.address);
String placeName = cusAddress.getText().toString();
Geocoder coder = new Geocoder(getApplicationContext());
try{
List<Address> addrList = coder.getFromLocationName(placeName, 3);
Iterator<Address> addrs = addrList.iterator();
String infoAddr = "";
double lat = 0f;
double lng = 0f;
while(addrs.hasNext())
{
Address loc = addrs.next();
infoAddr += String.format("Coord: %f. %f", loc.getLatitude(), loc.getLongitude());
lat = loc.getLatitude();
lng = loc.getLongitude();
}
intent.putExtra("lat", lat);
intent.putExtra("lng", lng);
}catch(IOException e){
}
startActivity(intent);
}
});
public class NaverMap extends NMapActivity implements OnMapStateChangeListener, OnMapViewTouchEventListener, OnCalloutOverlayListener{
NMapView mMapView = null;
NMapController mMapController = null;
NMapViewerResourceProvider mMapViewerResourceProvider = null;
NMapOverlayManager mOverlayManager;
//LinearLayout MapContainer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);// create map view
mMapView = new NMapView(this);// set a registered API key for Open MapViewer Library
mMapView.setApiKey("============");// set the activity content to the map view
setContentView(mMapView);// initialize map view
mMapView.setClickable(true);// register listener for map state changes
mMapView.setOnMapStateChangeListener(this);
mMapView.setOnMapViewTouchEventListener(this);// use map controller to zoom in/out, pan and set map center, zoom level etc.
mMapView.setBuiltInZoomControls(true, null);
mMapController = mMapView.getMapController();
/**********intent 값 얻어오기**********/
double lat = 0f;
double lng = 0f;
Intent intent = getIntent();
lat = intent.getDoubleExtra("lat", lat);
lng = intent.getDoubleExtra("lng", lng);
/**********오버레이 관련 코드 시작**********/
mMapViewerResourceProvider = new NMapViewerResourceProvider(this);
mOverlayManager = new NMapOverlayManager(this, mMapView, mMapViewerResourceProvider);
int markerId = NMapPOIflagType.PIN;
NMapPOIdata poiData = new NMapPOIdata(2, mMapViewerResourceProvider);
poiData.beginPOIdata(2);
poiData.addPOIitem(lng, lat, "위치1", markerId, 0);
poiData.endPOIdata();
NMapPOIdataOverlay poiDataOverlay
= mOverlayManager.createPOIdataOverlay(poiData, null);
poiDataOverlay.showAllPOIdata(0);
mOverlayManager.setOnCalloutOverlayListener(this);
/**********오버레이 관련 코드 끝**********/
}
public void onLongPress(NMapView arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
}
public void onLongPressCanceled(NMapView arg0) {
// TODO Auto-generated method stub
}
public void onScroll(NMapView arg0, MotionEvent arg1, MotionEvent arg2) {
// TODO Auto-generated method stub
}
public void onSingleTapUp(NMapView arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
}
public void onTouchDown(NMapView arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
}
public void onTouchUp(NMapView arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
}
public void onAnimationStateChange(NMapView arg0, int animType, int animState) {
// TODO Auto-generated method stub
}
public void onMapCenterChange(NMapView arg0, NGeoPoint arg1) {
// TODO Auto-generated method stub
}
public void onMapCenterChangeFine(NMapView arg0) {
// TODO Auto-generated method stub
}
public void onMapInitHandler(NMapView arg0, NMapError errorInfo) {
// TODO Auto-generated method stub
if (errorInfo == null) { // success
//mMapController.setMapCenter(new NGeoPoint(127.04500, 37.58000), 13);
} else { // fail
Log.e("NMAP", "onMapInitHandler: error=" + errorInfo.toString());
}
}
public void onZoomLevelChange(NMapView arg0, int arg1) {
// TODO Auto-generated method stub
}
public NMapCalloutOverlay onCreateCalloutOverlay(NMapOverlay arg0,
NMapOverlayItem arg1, Rect arg2) {
Toast.makeText(this, getTitle(), Toast.LENGTH_SHORT).show();
// TODO Auto-generated method stub
return null;
}
}