지금 위도 경도 수동으로 입력하여 위치는 찾아 냅니다..
근데 원하는건 위치를 표시 하게 하고 싶어서요;;; 지금 막 짜맞추기 햇는데 ㅠ
고수님들 도와주세요... 소스 추가 좀 부탁드려요;;
package com.test;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.google.android.maps.*;
public class test extends Activity {
private EditText lat;
private EditText lon;
//EditText txted = null;
//Button btnSimple = null;
MapView gMapView = null;
MapController mc = null;
//Drawable defaultMarker = null;
GeoPoint p = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.map);
lat = (EditText)findViewById(R.id.lat);
lon = (EditText)findViewById(R.id.lon);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
String _lat = lat.getText().toString();
String _lon = lon.getText().toString();
Uri uri = Uri.parse("geo:" + _lat + "," + _lon);
startActivity(new Intent(Intent.ACTION_VIEW,uri));
}
});
}
protected class MyLocationOverlay extends com.google.android.maps.Overlay {
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Paint paint = new Paint();
super.draw(canvas, mapView, shadow);
// Converts lat/lng-Point to OUR coordinates on the screen.
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(p, myScreenCoords);
paint.setStrokeWidth(1);
paint.setARGB(255, 255, 255, 255);
paint.setStyle(Paint.Style.STROKE);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint);
return true;
}
}
}
--------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1,2">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:paddingRight="4dip"
android:text="위도 경도:"/>
<EditText
android:id="@+id/lat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:editable="true"
android:singleLine="true"
android:layout_weight="1"/>
<EditText
android:id="@+id/lon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:editable="true"
android:singleLine="true"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="지도 보기!"
/>
</LinearLayout>
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear(); // 오버레이 리스트 지움
MyLocationOverlay mlo = new MyLocationOverlay(); // 고객 위치 오버레이
listOfOverlays.add(mlo);
추가해보세여 오버레이 구현만 하고 실제로 그려주는 부분이 없어서 그런듯